Created
January 8, 2012 08:30
-
-
Save itang/1577715 to your computer and use it in GitHub Desktop.
Scala implicit byname parameters
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
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