Look up a value by key with a fallback.

Map Basics

MapBasics.kt
fun main() {
    val code = 
    val points = mapOf("A" to 10, "B" to 7)
    val score = points[code] ?: 0
    val found = score > 0

    println("code=$code")
    println("score=$score")
    println("found=$found")
}
fun main() {
    val code = 
    val points = mapOf("A" to 10, "B" to 7)
    val score = points[code] ?: 0
    val found = score > 0

    println("code=$code")
    println("score=$score")
    println("found=$found")
}
fun main() {
    val code = 
    val points = mapOf("A" to 10, "B" to 7)
    val score = points[code] ?: 0
    val found = score > 0

    println("code=$code")
    println("score=$score")
    println("found=$found")
}
map A map stores values under keys.