Last active
August 13, 2018 06:08
-
-
Save NomadBlacky/50bcdcafaeac5d193dee300751f8e5e8 to your computer and use it in GitHub Desktop.
scala.reflect.ClassTag
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
| @ def foo[T: scala.reflect.ClassTag](obj: Any): Unit = obj match { | |
| case t: T => println(t.getClass.getName) | |
| case _ => println("ng") | |
| } | |
| defined function foo | |
| @ foo[Int](1) | |
| java.lang.Integer | |
| @ foo[String](1) | |
| ng | |
| @ foo[Int]("hoge") | |
| ng | |
| @ foo[String]("aa") | |
| java.lang.String |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment