不知道为什么下面的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。如果你导入collection.immutable.IndexedSeq
那么scala将成功编译。 (从OP复制)
关于scala编译错误: type mismatch; found: IndexedSeq[Int] required: scala. collection.immutable.Seq[Int],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13540002/