【发布时间】:2020-09-02 07:01:59
【问题描述】:
我创建了一个空的 scala 可变列表
import scala.collection.mutable.ListBuffer
val list_of_list : List[List[String]] = List.empty
我想在下面添加元素
filtered_df.collect.map(
r => {
val val_list = List(r(0).toString,r(4).toString,r(5).toString)
list_of_list += val_list
}
)
我得到的错误是
Error:(113, 26) value += is not a member of List[List[String]]
Expression does not convert to assignment because receiver is not assignable.
list_of_list += val_list
谁能帮忙
【问题讨论】:
-
您必须将
val list_of_list更改为var list_of_list并将list_of_list的类型更改为可变替代项