![]() Casting it to map make it immutable* (read-only) since MutableMap has Map as parent class Pairs.toMap(LinkedHashMap(mapCapacity(pairs.size))) it is mapping only the specified key to the specified value. a function that return an immutable map, which is serializable. Public static Map singletonMap(K key, V value) ![]() which return read-only empty map implementation In Kotlin, we have three functions for implementing maps and all of them are resolved using different implementations of Map. If you have focused on Map signature interface Map, it’s an interface, i.e it needs to have an implementing class. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |