Created
April 13, 2013 16:48
-
-
Save danidiaz/5379155 to your computer and use it in GitHub Desktop.
Scala type erasure gotcha.
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
// from here http://stackoverflow.com/questions/1094173/how-do-i-get-around-type-erasure-on-scala-or-why-cant-i-get-the-type-paramete | |
List(1,2,3) match { | |
case l : List[String] => println("A list of strings?!") | |
case _ => println("Ok") | |
} | |
// <console>:9: warning: fruitless type test: a value of type List[Int] cannot also be a List[String] (but still might match its erasure) | |
// case l : List[String] => println("A list of strings?!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment