clear
Требования к платформе и версии: Common (1.0), JS (1.1), Native (1.3), Wasm-JS (1.8), Wasm-WASI (1.8)
expect open override fun clear()
Удаляет все элементы из этой коллекции.
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val collection: MutableCollection<Char> = mutableSetOf('a', 'b', 'c')
println(collection) // [a, b, c]
collection.clear()
println(collection) // []
//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/-hash-set/clear.html