Skip to content

Instantly share code, notes, and snippets.

@itang
Created January 8, 2012 08:30
Show Gist options
  • Save itang/1577715 to your computer and use it in GitHub Desktop.
Save itang/1577715 to your computer and use it in GitHub Desktop.
Scala implicit byname parameters
package a
object Main {
//implicit val it: String => Any = s => println(s)
def f(text: String)(implicit proc: String ⇒ Any) {
proc(text)
}
// def f(text: String) {
// //proc(text)
// }
// def f1(text: String)(implicit proc: ⇒ Any) {
// proc
// }
def f2(text: String)(proc: ⇒ Any) {
proc
}
def main(args: Array[String]) {
f("hello")
f("hello"){ it ⇒
println
}
f("hello"){ it ⇒
println(it)
"ss"
}
// f("hello"){
// println("world")
// }
f2("hello")()
f2("hello"){}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment