If you need to use both mutable and immutable collections in the same file, the canonical solution is simply for the mutable or immutable prefix explicitly.
import collection._ val myMutableSet: mutable.Set[Int] = mutable.Set(1, 2, 3) val myImmutableSet: immutable.Set[Int] = immutable.Set(1, 2, 3)
As Kim Stebel noted in his answer, you can also use rename imports:
import scala.collection.mutable.{Set => MutableSet}
However, mutable.Set is only one character larger than MutableSet , and does not introduce any new name so you can simply use the old form.
source share