W3cubDocs

/Kotlin

isNotEmpty

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Array<out T>.isNotEmpty(): Boolean
fun ByteArray.isNotEmpty(): Boolean
fun ShortArray.isNotEmpty(): Boolean
fun IntArray.isNotEmpty(): Boolean
fun LongArray.isNotEmpty(): Boolean
fun FloatArray.isNotEmpty(): Boolean
fun DoubleArray.isNotEmpty(): Boolean
fun BooleanArray.isNotEmpty(): Boolean
fun CharArray.isNotEmpty(): Boolean

Returns true if the array is not empty.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Collection<T>.isNotEmpty(): Boolean

Returns true if the collection is not empty.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val empty = emptyList<Any>()
println("empty.isNotEmpty() is ${empty.isNotEmpty()}") // false

val collection = listOf('a', 'b', 'c')
println("collection.isNotEmpty() is ${collection.isNotEmpty()}") // true
//sampleEnd
}
Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <K, V> Map<out K, V>.isNotEmpty(): Boolean

Returns true if this map is not empty.

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/is-not-empty.html