is Empty
Версия Kotlin: 1.0
expect open override fun isEmpty(): Boolean
Возвращает true, если коллекция пуста (не содержит элементов), и false в противном случае.
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val collection: MutableCollection<Int> = mutableListOf(1, 2, 3)
println(collection.size) // 3
println("collection.isEmpty() is ${collection.isEmpty()}") // false
collection.clear()
println(collection.size) // 0
println("collection.isEmpty() is ${collection.isEmpty()}") // true
//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/-linked-hash-set/is-empty.html