0

Kotlin – Check if key exists in Map

This post shows an sample codes that checks if a key exists in a map. There are 3 ways to do this in Kotlin. We are using Kotlin 1.1.

Map.containsKey(key: String)

Map.contains(key: String)

This one is a bit special. The documentation says:

x in map

References

https://kotlinlang.org/docs/reference/collections.html

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert