none
Returns true
if the array has no elements.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
assertTrue(emptyList.none())
val nonEmptyList = listOf("one", "two", "three")
assertFalse(nonEmptyList.none())
//sampleEnd
}
Returns true
if no elements match the given predicate.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val isEven: (Int) -> Boolean = { it % 2 == 0 }
val zeroToTen = 0..10
assertFalse(zeroToTen.none { isEven(it) })
assertFalse(zeroToTen.none(isEven))
val odds = zeroToTen.map { it * 2 + 1 }
assertTrue(odds.none { isEven(it) })
val emptyList = emptyList<Int>()
assertTrue(emptyList.none { true })
//sampleEnd
}
Returns true
if the collection has no elements.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
assertTrue(emptyList.none())
val nonEmptyList = listOf("one", "two", "three")
assertFalse(nonEmptyList.none())
//sampleEnd
}
Returns true
if the map has no entries.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
assertTrue(emptyList.none())
val nonEmptyList = listOf("one", "two", "three")
assertFalse(nonEmptyList.none())
//sampleEnd
}
inline fun <K, V> Map<out K, V>.none(predicate: (Map.Entry<K, V>) -> Boolean): Boolean
Content copied to clipboard
Returns true
if no entries match the given predicate.
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val isEven: (Int) -> Boolean = { it % 2 == 0 }
val zeroToTen = 0..10
assertFalse(zeroToTen.none { isEven(it) })
assertFalse(zeroToTen.none(isEven))
val odds = zeroToTen.map { it * 2 + 1 }
assertTrue(odds.none { isEven(it) })
val emptyList = emptyList<Int>()
assertTrue(emptyList.none { true })
//sampleEnd
}
Returns true
if the array has no elements.
Since Kotlin
1.3
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val emptyList = emptyList<Int>()
assertTrue(emptyList.none())
val nonEmptyList = listOf("one", "two", "three")
assertFalse(nonEmptyList.none())
//sampleEnd
}
Returns true
if no elements match the given predicate.
Since Kotlin
1.3
Samples
import samples.*
import kotlin.test.*
fun main() {
//sampleStart
val isEven: (Int) -> Boolean = { it % 2 == 0 }
val zeroToTen = 0..10
assertFalse(zeroToTen.none { isEven(it) })
assertFalse(zeroToTen.none(isEven))
val odds = zeroToTen.map { it * 2 + 1 }
assertTrue(odds.none { isEven(it) })
val emptyList = emptyList<Int>()
assertTrue(emptyList.none { true })
//sampleEnd
}