如何绕过Scala上的类型擦除?或者,为什么不能获得集合的类型参数?
scala> List(1,2,3) match { | case l : List[String] => println("A list of strings?!") | case _ => println("Ok") | }warning: there were unchecked warnings; re-run with -unchecked for details A list of strings?!
scala> List(1,2,3) match { | case l : List[String] => println("A list of strings?!") | case _ => println("Ok") | }<console>:6: warning: non variable type-argument String in type pattern is unchecked since it is eliminated by erasure case l : List[String] => println("A list of strings?!") ^A list of strings?!
杨魅力
白猪掌柜的
相关分类