Map Creation in Kotlin
Level 286 keystrokes
Creates a read-only map and reads a value and its size.
Kotlin code
// mapOf creates a read-only map of key-value pairs// "Alice" to 25 uses the infix function to and creates a Pair1val ages = mapOf("Alice" to 25, "Bob" to 30)// [key] returns the value for that key: 252println(ages["Alice"])// size returns the number of entries: 23println(ages.size)Output
25 2
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Kotlin code and how often they appear.
"× 6(× 3)× 3,× 1.× 1[× 1]× 1=× 1