I have a list of Scala. I can destroy the list into some variables this way:
var a :: b :: tail = myList
a should be ("A1")
b should be ("B1")
tail should be ('empty)
However, it seems that I cannot reuse the same variables for another destructuring:
a :: b :: tail = anotherList
a should be ("A2")
b should be ("B2")
tail should be ('empty)
The compiler tells me that he expected a half-colony, but found an equal sign. Why is this? Is it impossible to use already declared variables during destruction? Am I doing something stupid?
source
share