contains Key
Начиная с Kotlin: 1.1
open override fun containsKey(key: K): Boolean
Возвращает true, если карта содержит указанный ключ.
Примеры
import kotlin.test.*
import java.util.*
fun main() {
//sampleStart
val map = mapOf(1 to "one", 2 to "two")
println("map.containsKey(1) is ${map.containsKey(1)}") // true
println("map.containsKey(-1) is ${map.containsKey(-1)}") // false
//sampleEnd
}
© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-abstract-map/contains-key.html