Created
October 14, 2016 21:15
-
-
Save travisbrown/bbd1162b8bc7d2bf39e29fadf55db223 to your computer and use it in GitHub Desktop.
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
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