Let us see Map in details
- Map is Iterable of Key and Value pairs
- Each element can be defined as
key -> valueor
- Here is the link for official documentation – http://docs.scala-lang.org/overviews/collections/maps
- Let us create case class Order
- Additions and updates
updated, which let you add new bindings to a map or change existing bindings.
--, which remove bindings from a map.
- Additions and removals can be performed on mutable Maps by using +=, ++=, -= and –=
- Lookup operations such as
isDefinedAtcan be performed on Map
- Subcollection producers
valuesIterator, which return a map’s keys and values separately in various forms.
mapValues, which produce a new map by filtering and transforming bindings of an existing map.
- There are many concrete Map classes. We need to evaluate as and when situation demands. For now understanding Map is more than enough.