Forked from travisbrown/eta-expansion-implicits.scala
Created
October 14, 2016 21:33
-
-
Save xuwei-k/e0a556e8ae91e9eb5e0ad4e221a9c055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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