当然,如果工作中需要对列表元素进行修改,可以构造可变列表,使用ListBuffer函数即可,该函数需要导入scala.collection.mutable模块
// 构造不可变列表
val ls1 =...(1, 1, 2, 3, 5, 8, 13, 21, 36)
ls3 = ListBuffer(1, 1, 2, 3, 5, 8, 13, 21, 36, 57)
ls3 = ListBuffer(1,...1, 2, 3, 5, 8, 13, 21, 36, 57, 10, 22, 16, 4, 8)
ls3 = ListBuffer(1, 1, 2, 100, 3, 5, 8, 13, 21, 36,...(2, 100, 3, 5, 8, 13, 21, 36, 57, 10, 22, 16, 4, 8)
ls3 = ListBuffer(2, 100, 3, 5, 8, 13, 21, 36, 57,...10, 22, 16)
ls3 = ListBuffer(100, 3, 5, 8, 13, 21, 36, 57, 10, 16)
可变列表的改
如果工作中设计到可变列表元素的修改时,便可以借助于“