Skip to content

Instantly share code, notes, and snippets.

@jstrachan
Created March 16, 2010 12:47
Show Gist options
  • Select an option

  • Save jstrachan/333926 to your computer and use it in GitHub Desktop.

Select an option

Save jstrachan/333926 to your computer and use it in GitHub Desktop.
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