25 Maps
- Maps are constructed simply using
Map(key1 -> value1, key2 -> value2, ...)
- The Map can contain mixed types, but the final type of the Map keys / values will be the lowest common denominator type
- The default
Map
is Predef.Map
which points to scala.collection.immutable.Map
- As it currently stands, Map implementation up to size of 4 has a specific class Map1, Map2, Map3, Map4, beyond that, it uses an immutable
HashMap
- You can’t have duplicate keys, adding a key value pair whose key already exists, overwrites the value
- Order of iteration is not guaranteed to be consistent
See Also opens in new page