Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save xuwei-k/e0a556e8ae91e9eb5e0ad4e221a9c055 to your computer and use it in GitHub Desktop.
Save xuwei-k/e0a556e8ae91e9eb5e0ad4e221a9c055 to your computer and use it in GitHub Desktop.
class TC[A](val x: String)
object TC {
def getX[A: TC](a: A): String = implicitly[TC[A]].x
implicit def anyTC[A]: TC[A] = new TC[A]("*")
implicit val stringTC: TC[String] = new TC[String]("String")
}
object Example {
val strings = List("a", "b")
val ee1 = strings.map(TC.getX)
val ee2 = strings.map(TC.getX _)
val af1 = strings.map(TC.getX(_))
val af2 = strings.map(s => TC.getX(s))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment