none
Returns true
if the array has no elements.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
println("emptyList.none() is ${emptyList.none()}") // true
val nonEmptyList = listOf("one", "two", "three")
println("nonEmptyList.none() is ${nonEmptyList.none()}") // false
//sampleEnd
}
Returns true
if no elements match the given predicate.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val isEven: (Int) -> Boolean = { it % 2 == 0 }
val zeroToTen = 0..10
println("zeroToTen.none { isEven(it) } is ${zeroToTen.none { isEven(it) }}") // false
println("zeroToTen.none(isEven) is ${zeroToTen.none(isEven)}") // false
val odds = zeroToTen.map { it * 2 + 1 }
println("odds.none { isEven(it) } is ${odds.none { isEven(it) }}") // true
val emptyList = emptyList<Int>()
println("emptyList.none { true } is ${emptyList.none { true }}") // true
//sampleEnd
}
Returns true
if the collection has no elements.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
println("emptyList.none() is ${emptyList.none()}") // true
val nonEmptyList = listOf("one", "two", "three")
println("nonEmptyList.none() is ${nonEmptyList.none()}") // false
//sampleEnd
}
Returns true
if the map has no entries.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
println("emptyList.none() is ${emptyList.none()}") // true
val nonEmptyList = listOf("one", "two", "three")
println("nonEmptyList.none() is ${nonEmptyList.none()}") // false
//sampleEnd
}
Returns true
if no entries match the given predicate.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
//sampleStart
val isEven: (Int) -> Boolean = { it % 2 == 0 }
val zeroToTen = 0..10
println("zeroToTen.none { isEven(it) } is ${zeroToTen.none { isEven(it) }}") // false
println("zeroToTen.none(isEven) is ${zeroToTen.none(isEven)}") // false
val odds = zeroToTen.map { it * 2 + 1 }
println("odds.none { isEven(it) } is ${odds.none { isEven(it) }}") // true
val emptyList = emptyList<Int>()
println("emptyList.none { true } is ${emptyList.none { true }}") // true
//sampleEnd
}
Returns true
if the array has no elements.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
println("emptyList.none() is ${emptyList.none()}") // true
val nonEmptyList = listOf("one", "two", "three")
println("nonEmptyList.none() is ${nonEmptyList.none()}") // false
//sampleEnd
}
Returns true
if no elements match the given predicate.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
//sampleStart
val isEven: (Int) -> Boolean = { it % 2 == 0 }
val zeroToTen = 0..10
println("zeroToTen.none { isEven(it) } is ${zeroToTen.none { isEven(it) }}") // false
println("zeroToTen.none(isEven) is ${zeroToTen.none(isEven)}") // false
val odds = zeroToTen.map { it * 2 + 1 }
println("odds.none { isEven(it) } is ${odds.none { isEven(it) }}") // true
val emptyList = emptyList<Int>()
println("emptyList.none { true } is ${emptyList.none { true }}") // true
//sampleEnd
}