...

/

Map Operations

Map Operations

Explore essential map operations, including checking for key existence, determining map size, iterating through maps, and working with mutable maps.

Checking if a map contains a key

We can check if our map contains a key using the in keyword or the containsKey method.

Press + to interact
fun main() {
val map = mapOf('A' to "Alex", 'B' to "Bob")
println('A' in map) // true
println(map.containsKey('A')) // true
println('Z' in map) // false
println(map.containsKey('Z')) // false
}

Checking map size

...