让不可变Seq的不可变Seq为:
val content: Seq[Seq[Double]
我希望转换为可变Seqs的可变Seq:
val mutable_being_inversed_matrix:
collection.mutable.Seq[collection.mutable.Seq[Double]] =
content.to[collection.mutable.Seq[collection.mutable.Seq[Double]]
但这会产生以下错误:
Error:(79, 128)
scala.collection.mutable.Seq[scala.collection.mutable.Seq[Double]]
takes no type parameters, expected: one
val mutable_being_inversed_matrix: collection.mutable.Seq[collection.mutable.Seq[Double]] = content.to[collection.mutable.Seq[collection.mutable.Seq[Double]]]
如何处理?
答案 0 :(得分:2)
鉴于这种不可变的输入:
val immutableInput = Seq(Seq(1, 2), Seq(4))
你可以使用varargs constructor切换到可变Seqs的可变Seq:
scala.collection.mutable.Seq(
immutableInput.map(imseq => scala.collection.mutable.Seq(imseq:_*)):_*
)
产生:
res0: scala.collection.mutable.Seq[scala.collection.mutable.Seq[Int]] =
ArrayBuffer(ArrayBuffer(1, 2), ArrayBuffer(4))