clear

expect open override fun clear()(source)

Removes all elements from this collection.

Since Kotlin

1.3

Samples

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
}
actual open override fun clear()(source)

Removes all elements from this collection.

Since Kotlin

1.1

Samples

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
}
actual open override fun clear()(source)

Removes all elements from this collection.

Since Kotlin

1.3
actual open override fun clear()(source)

Removes all elements from this collection.

Since Kotlin

1.8
actual open override fun clear()(source)

Removes all elements from this collection.

Since Kotlin

1.8