In Kotlin it is possible to use bracket notation with a Map, so the following code:
val mapOfMap: Map<String, Map<String, String>> = mapOf("Key1" to mapOf("Subkey1" to "Value1", "Subkey2" to "Value2"))
println(mapOfMap["Key1"])
prints:
{Subkey1=Value1, Subkey2=Value2}
That's great. But why can't I do the following
println(mapOfMap["Key1"]["Subkey1"])
It causes a compilation error: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Map?
What is the proper way to handle this?