
Since we are creating Maps using Pair, let’s focus on what is it?

signatureĪ map contains a Set> type entries to store its key/value, since its a Set, the uniqueness is enforced into the map entries. Map is not an inheritor of the Collection Interface, but it’s the part of the Kotlin Collection type.Īn entry represents a key/value pair in a map.The modifying part is supported using Mutable maps, discussed later in the article.The map is a read-only collection but for the sake of understanding, I will be addressing it as Immutable*.A map can hold only one value against a key.Keys are unique and similar to the index of an array.It’s a collection of key-value pairs, mainly focus on retrieving a value against the key. I’m Chetan Gupta, I do tech stuff, don’t forget to checkout from other blogs as well from AndroidBites, without any delays, Let’s get started. Disclaimer This article is specific to Kotlin JVM as collection implementation varies with the platform you are targeting in Kotlin. In Today’s article, we will try to understand how Kotlin catered to Java Maps in his its colors. Kotlin stdlib which offers generic interfaces, classes, and functions for creating, populating, and managing Collections of any type. You could end up with a spaghetti codebase base having a long trailing function and making hacks to achieve a functionality that could easily be solved using Kotlin’s standard functions easily.

Most of the Kotlin developers are migrated from the Java environment, they are pretty well versed with uses-cases and application of Collection Framework in the Java platform, but applying the same knowledge in a Kotlin codebase isn’t guaranteed to work always.
