How do I make a null safe equals comparison?
This is not valid Kotlin code:
val map: Map<String, JsonElement>?
if (map?["some_key"]? == "some_value") { ... }
How do I write that correctly? If map
is null
or the key isn’t in it then the ==
should evaluate to false.