#collections #maps #scala
If we want to add a key-value pair to a Map, we can use the operator + as follows:
A += ('I' -> 1)
A += ('J' -> 5)
A += ('K' -> 10)
A += ('L' -> 100)
If you want to change selection, open document below and click on "Move attachment"
Scala Mapsh keys and values.
val colors = Map("red" -> "#FF0000", "azure" -> "#F0FFFF")
While defining empty map, the type annotation is necessary as the system needs to assign a concrete type to variable. <span>If we want to add a key-value pair to a Map, we can use the operator + as follows:
A += ('I' -> 1)
A += ('J' -> 5)
A += ('K' -> 10)
A += ('L' -> 100)
Basic Operations on Map:
All operations on maps can be expressed in terms of the following three methods:
MethodsDescriptionkeysThis method returns an iterable containing each key in the Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details