Collections · 31 of 42
One thing to note is the difference between the +=, ++=, -=, --= etc. functions regarding mutable and immutable collections.
var instead of val then the Scala compiler expands them to variable = variable op param (see on the left for an example)import scala.collection.mutable var immutableSet = Set(1, 2, 3) immutableSet += 4 //this is the same as: immutableSet = immutableSet + 4 //compare to val mutableSet = mutable.Set(1, 2, 3) mutableSet += 4 // this is the same as: mutableSet.+=(4) println(immutableSet) println(mutableSet)