Logo

Programming-Idioms

History of Idiom 8 > diff from v71 to v72

Edit summary for version 72 by LeonAKM:
[Kotlin] Wrong, mapOF immutable

Version 71

2020-04-29, 09:26:44

Version 72

2020-05-03, 08:28:31

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Idiom #8 Initialize a new map (associative array)

Declare a new map object x, and provide some (key, value) pairs as initial content.

Variables
x
Extra Keywords
table dictionary hash
Extra Keywords
table dictionary hash
Code
val x = mapOf<String, Integer>()
x["one"] = 1
x["two"] = 2
Code
val x = mutableMapOf<String, Integer>()
x["one"] = 1
x["two"] = 2
Doc URL
https://kotlinlang.org/docs/reference/constructing-collections.html
Doc URL
https://kotlinlang.org/docs/reference/constructing-collections.html