#collections #scala #sets
If you want to use both mutable and immutable sets in the same, then you can continue to refer to the immutable Set as Set but you can refer to the mutable Set as mutable.Set.
If you want to change selection, open document below and click on "Move attachment"
Scala Sets and immutable objects is that when an object is immutable, the object itself can't be changed.
By default, Scala uses the immutable Set. If you want to use the mutable Set, you'll have to import scala.collection.mutable.Set class explicitly. <span>If you want to use both mutable and immutable sets in the same, then you can continue to refer to the immutable Set as Set but you can refer to the mutable Set as mutable.Set. Following is the example to declare immutable Sets as follows:
// Empty set of integer type
var s : Set[Int] = Set()
// Set of integer type
var s : Set[Int] = Set(1,3,5,7)
or
var s = Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details