Skip to content

Instantly share code, notes, and snippets.

@kevinlynx
Last active December 24, 2015 21:39
Show Gist options
  • Save kevinlynx/6866861 to your computer and use it in GitHub Desktop.
Save kevinlynx/6866861 to your computer and use it in GitHub Desktop.
implicit parameter
// `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