Scala Map is a collection of Key-value pair. A map cannot have duplicate keys but different keys can have same values i.e keys are unique whereas values can be duplicate.
Maps in Scala are not language syntax. They are library abstractions that you can extend and adapt.
Scala provides mutableand immutable alternatives for maps. Class hierarchy for scala maps is shown below:
Image is taken from Programming in Scala by Martin Odersky
There’s a base Map trait in package scala.collection, and two subtraits – a mutable Mapin scala.collection.mutableand an immutable one in scala.collection.immutable . By default Scala Map is immutable but if you want to use mutable one then you need to import mutable Map by using statement : import scala.collection.mutable
View original post 1,282 more words