Given that default implementation of a Set is immutable:
val Set = immutable.Set
And in order to make it mutable one needs to import
import scala.collection.mutable.Set;
In event one needs to use both mutable and immutable Sets in a given file, how should one go about it?
When you need to use both mutable and immutable collections in the same file, the canonical solution is just to prefix with
mutableorimmutableexplicitly.AS Kim Stebel mentioned in his answer, you can also use a renaming import:
However
mutable.Setis only one character more thanMutableSet, and does not introduce any new name so you might as well just use the former form.