10 Maps
The third commonly used type of collection in Kotlin is Map. The Map type has a lot in common with the List and Set types: All three group elements, are read-only by default, use parameterized types to tell the compiler the type of their contents, and support iteration.
Where Map is different from List and Set is that its elements consist of key-value pairs, and instead of index-based access using an integer, a map provides key-based access using a type that you specify. Keys are unique and identify the values in the map; values, on the other hand, do not need to be unique. In this way, Map shares another feature with Set: The keys of a map are guaranteed to be unique, just like the elements of a set.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access