Created
November 3, 2015 12:44
-
-
Save eiennohito/b82d5954a0acdf49cbad 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
int 1,2,3 | |
long 1,2,3 | |
Process finished with exit code 0 |
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
trait A[T] { | |
def name: String | |
} | |
object A { | |
implicit object Aint extends A[Int] { def name = "int" } | |
implicit object Along extends A[Long] { def name = "long" } | |
} | |
class C { | |
def x[T: A](ts: Seq[T]) = println(s"${implicitly[A[T]].name} ${ts.mkString(",")}") | |
} | |
object D { | |
def main(args: Array[String]): Unit = { | |
val c = new C | |
c.x(List(1, 2, 3)) | |
c.x(List(1L, 2L, 3L)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment