By changing a key that does not exist on the map, you basically change the default value, rather than adding a new key.
Suppose you want to add some things to install using the key a
on your card.
val mmap =
mutable.Map[ String, mutable.Set[ String ] ]()
.withDefaultValue( mutable.Set[ String ]() )
mmap( "a" ) += "b"
mmap( "a" ) += "c"
Now the default value mmap
has 2 elements, but still no keys. Now you are changing another non-existent key:
// Still changind default value
mmap( "c" ) += "c1"
-
println( mmap("a") )
// Creating a new key
mmap("b") = mutable.Set[ String ]( "b1", "b2" )
mmap.foreach( println )
// Result => (b,Set(b1, b2))