Map Operations
Explore essential map operations, including checking for key existence, determining map size, iterating through maps, and working with mutable maps.
We'll cover the following...
We'll cover the following...
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
Kotlin 1.5
fun main() {val map = mapOf('A' to "Alex", 'B' to "Bob")println('A' in map) // trueprintln(map.containsKey('A')) // trueprintln('Z' in map) // falseprintln(map.containsKey('Z')) // false}