Kotlin - Collections Fundamentals
Which Kotlin expression safely accesses the value for key "x" in a map and returns 0 if the key is missing?
map["x"] returns the value or null if key is missing. The Elvis operator ?: provides a default value if null.?: 0 to return 0 if key "x" is missing. map.get("x") returns nullable value without default. map["x"]!! forces non-null and throws if missing. map.getValue("x") throws if key missing.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions