我的 sbt 显示警告消息
non-variable type argument String in type pattern List[String] (the underlying of List[String]) is unchecked since it is eliminated by erasure
我尝试了链接中给出的答案(第一个解决方案)
scala 中的擦除消除:非变量类型参数未被选中,因为它是通过擦除消除的 https://stackoverflow.com/questions/25222989/erasure-elimination-in-scala-non-variable-type-argument-is-unchecked-since-it
这是我的代码
case class ListStrings(values:scala.List[String]) { }
def matchValue(value: Any) = {
value match {
case ListStrings(xs) =>
val userList = xs
case _ => log.error("unknown value")
}
}
val list: List[String] = List("6","7","8")
matchValue(list)
我得到“未知值”作为输出,为什么它不匹配?我在这里缺少什么?
因为你通过了list
代替ListStrings(list)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)