Skip to content

Instantly share code, notes, and snippets.

@hyunjun
Created September 21, 2020 02:38
Show Gist options
  • Save hyunjun/be0a11583dfcb41f4273e5957e1c8022 to your computer and use it in GitHub Desktop.
Save hyunjun/be0a11583dfcb41f4273e5957e1c8022 to your computer and use it in GitHub Desktop.
Scala Implicit
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