Logo

Programming-Idioms

History of Idiom 8 > diff from v69 to v70

Edit summary for version 70 by hover:
New Kotlin implementation by user [hover]

Version 69

2020-04-29, 09:23:01

Version 70

2020-04-29, 09:24:22

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.

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