繁体   English   中英

scala编译错误:类型不匹配; found:需要IndexedSeq [Int]:scala.collection.immutable.Seq [Int]

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM