keys

expect open override val keys: MutableSet<K>(source)

Returns a MutableSet of all keys in this map.

Since Kotlin

1.3

Samples

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
}
actual open override val keys: MutableSet<K>(source)

Returns a read-only Set of all keys in this map.

Accessing this property first time creates a keys view from entries. All subsequent accesses just return the created instance.

Since Kotlin

1.1
actual open override val keys: MutableSet<K>(source)

Returns a read-only Set of all keys in this map.

Accessing this property first time creates a keys view from entries. All subsequent accesses just return the created instance.

Since Kotlin

1.3
actual open override val keys: MutableSet<K>(source)

Returns a read-only Set of all keys in this map.

Accessing this property first time creates a keys view from entries. All subsequent accesses just return the created instance.

Since Kotlin

1.8
actual open override val keys: MutableSet<K>(source)

Returns a read-only Set of all keys in this map.

Accessing this property first time creates a keys view from entries. All subsequent accesses just return the created instance.

Since Kotlin

1.8