Getting familiar with Map and DynamicMap
Similar to lists, maps are one of the most popular data structures that are broadly implemented in various programming languages. A map is a collection of key-value pairs with the characteristic that the key must be unique while the values can repeat inside of a map.
In this section, we will describe two data types in Bosque – Map
and DynamicMap
. The difference between them is that the former – similar to the List
concept – creates an immutable Map instance, which means that once it has been instantiated with some values, you cannot change it. The latter allows you to modify the map once it's been created. Both Map
and DynamicMap
provide the Expandoable
concept, which means that the spread operator can be used on them.
First thing's first, let's see how a Map
can be instantiated. The following example shows how to create a Map
instance in Bosque:
let map = Map<String, Int>@{ ...