As said in the title, I can't reassign a variable of type Arraybuffer(Arraybuffer(Int,Int),Int)
in a for loop
:
var ab1 = ArrayBuffer(le4: _*)
var ab2 = ab1 map (ligne => (ArrayBuffer(ligne._1: _*), ligne._2))
println("ab:" + ab2)
for {
i <- 1 to ab2.length
j <- 0 to i
} {
ab2(i)._1(j)._2 = j match {
case 0 => ab2(i - 1)._1(0)._2 + ab2(i)._1(j)._1
case i => ab2(i - 1)._1(j - 1)._2 + ab2(i)._1(j)._1
case _ => ab2(i - 1)._1(j)._2 + ab2(i - 1)._1(j - 1)._1 + ab2(i)._1(j)._1
}
}
the key point is that ab2
is declared as var but the change of an Int inside it is denied. Why?