Created
November 1, 2011 13:21
-
-
Save mushtaq/1330483 to your computer and use it in GitHub Desktop.
For patrick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Block[T] extends Function1[String, T] | |
object Block { | |
implicit def functionBlock[T](f: String => T): Block[T] = new Block[T] { | |
def apply(s: String): T = f(s) | |
} | |
implicit val unitBlock: Block[Unit] = new Block[Unit] { | |
def apply(s: String): Unit = {} | |
} | |
} | |
object A { | |
def get[T](uri: String)(implicit block: Block[T]): T = { | |
println("before...") | |
val result = block(uri.reverse) | |
println("after...") | |
result | |
} | |
val result = get("http") { | |
r: String => println(r); 42 | |
} | |
val result1 = get("http") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment