keys
Returns a MutableSet of all keys in this map.
Since Kotlin
1.0Samples
import kotlin.test.*
import java.util.*
fun main() {
//sampleStart
val map = mutableMapOf(1 to "one", 2 to "two")
val keys = map.keys
println(keys) // [1, 2]
keys.remove(1)
println(keys) // [2]
println(map) // {2=two}
// keys.add(3) // will fail with UnsupportedOperationException
//sampleEnd
}
Returns a MutableSet of all keys in this map.
Since Kotlin
1.3Samples
import kotlin.test.*
import java.util.*
fun main() {
//sampleStart
val map = mutableMapOf(1 to "one", 2 to "two")
val keys = map.keys
println(keys) // [1, 2]
keys.remove(1)
println(keys) // [2]
println(map) // {2=two}
// keys.add(3) // will fail with UnsupportedOperationException
//sampleEnd
}
Returns a MutableSet of all keys in this map.
Since Kotlin
1.8Samples
import kotlin.test.*
import java.util.*
fun main() {
//sampleStart
val map = mutableMapOf(1 to "one", 2 to "two")
val keys = map.keys
println(keys) // [1, 2]
keys.remove(1)
println(keys) // [2]
println(map) // {2=two}
// keys.add(3) // will fail with UnsupportedOperationException
//sampleEnd
}
Returns a MutableSet of all keys in this map.
Since Kotlin
1.8Samples
import kotlin.test.*
import java.util.*
fun main() {
//sampleStart
val map = mutableMapOf(1 to "one", 2 to "two")
val keys = map.keys
println(keys) // [1, 2]
keys.remove(1)
println(keys) // [2]
println(map) // {2=two}
// keys.add(3) // will fail with UnsupportedOperationException
//sampleEnd
}