Created
March 16, 2010 12:47
-
-
Save jstrachan/333926 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| scala> def tag(body:() => String) { println("start"); println("body = " + body()); println("end") } | |
| tag: (body: () => String)Unit | |
| scala> implicit def blockToStringFunction(body: () => Unit): () => String = () => { println("capturing"); body(); "answer" } | |
| blockToStringFunction: (body: () => Unit)() => String | |
| scala> tag { println("line1"); println("line2") } | |
| <console>:7: error: type mismatch; | |
| found : Unit | |
| required: () => String | |
| tag { println("line1"); println("line2") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment