-
-
Save hyunjun/be0a11583dfcb41f4273e5957e1c8022 to your computer and use it in GitHub Desktop.
Scala Implicit
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
implicit val num = 2 | |
implicit val item = "Orange" | |
def shopping(implicit num: Int, item: String): String = | |
s"I'm buying $num $item${if (num == 1) "" else "s"}." | |
println(shopping(implicitly[Int], "Something")) | |
println(shopping(999, implicitly[String])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment