scala编译错误:类型不匹配; found:需要IndexedSeq [Int]:scal
发布时间:2020-12-16 18:35:12 所属栏目:安全 来源:网络整理
导读:我不知道为什么以下 scala代码无法编译: import collection.immutable.Seqdef foo(nodes: Seq[Int]) = nullval nodes:IndexedSeq[Int] = nullfoo(nodes) = error: type mismatch; found : IndexedSeq[Int] required: scala.collection.immutable.Seq[Int] f
我不知道为什么以下
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复制)
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读