Last active
December 24, 2015 21:39
-
-
Save kevinlynx/6866861 to your computer and use it in GitHub Desktop.
implicit parameter
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
// `s' and `b' are both implicit parameters | |
def implFn(i: Int)(implicit s: String, b: Int) = { | |
println(s) | |
i + b | |
} | |
def main(args: Array[String]) { | |
// otherS will match parameter `s' by type, **not by name** | |
implicit val otherS = "hello" | |
// error, two variables with the same type | |
//implicit val myS = "world" | |
implicit val otherB = 101 | |
println(implFn(1)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment