Skip to content

Instantly share code, notes, and snippets.

@danidiaz
Created April 13, 2013 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danidiaz/5379155 to your computer and use it in GitHub Desktop.
Save danidiaz/5379155 to your computer and use it in GitHub Desktop.
Scala type erasure gotcha.
// 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