<In Kotlin, how do I idiomatically access nullable...
# stackoverflow
u
In Kotlin, how do I idiomatically access nullable nested map values, or return a default? Quick Kotlin best practices question, as I couldn't really work out the best way to do this from the documentation. Assume I have the following nested map (typing specified explicitly for the purpose of this question): val userWidgetCount: Map = mapOf( "rikbrown" to mapOf( "widgetTypeA" to 1, "widgetTypeB" to 2)) Can the following mode be any more succinct? fun getUserWidgetCount(username: String, widgetType: String): Int { return...