![](/img/trans.png)
[英]How can I fix mismatch error in scala where the found : Seq[scala.collection.immutable.Seq required: scala.collection.Seq?
[英]scala compile error: type mismatch; found: IndexedSeq[Int] required: scala.collection.immutable.Seq[Int]
我不知道为什么以下scala代码无法编译:
import collection.immutable.Seq
def foo(nodes: Seq[Int]) = null
val nodes:IndexedSeq[Int] = null
foo(nodes)
=>
error: type mismatch;
found : IndexedSeq[Int]
required: scala.collection.immutable.Seq[Int]
foo(nodes)
^
在scala-library中,声明了IndexedSeq:
trait IndexedSeq[+A] extends Seq[A]...
有几个IndexedSeq特征。 默认为scala.collection.IndexedSeq
。 如果import collection.immutable.IndexedSeq
则scala将成功编译。 (从OP复制)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.