none

suspend fun <T> Flow<T>.none(predicate: suspend (T) -> Boolean): Boolean(source)

A terminal operator that returns true if no elements match the given predicate, or returns false and cancels the flow as soon as the first element matching the predicate is encountered.

If the flow terminates without emitting any elements, the function returns true because there are no elements in it that match the predicate. See a more detailed explanation of this logic concept in the "Vacuous truth" article.

Equivalent to !any(predicate) (see Flow.any) and all { !predicate(it) } (see Flow.all).

Example:

val myFlow = flow {
repeat(10) {
emit(it)
}
throw RuntimeException("You still didn't find the required number? I gave you ten!")
}
println(myFlow.none { it 5 }) // false
println(flowOf(1, 2, 3).none { it 5 }) // true

See also