any
Tests whether the array is non-empty (no-arg form) or whether at least one element satisfies the given predicate. Returns false for empty arrays when a predicate is provided.
Signatures
fun <T, D : Dimension> MultiArray<T, D>.any(): Boolean
inline fun <T, D : Dimension> MultiArray<T, D>.any(
predicate: (T) -> Boolean
): Boolean
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Condition to test each element against. |
Returns:
Without predicate:
trueif the array is not empty.With predicate:
trueif at least one element satisfiespredicate. Returnsfalsefor empty arrays.
Example
val a = mk.ndarray(mk[1, 2, 3, 4])
a.any() // true
a.any { it > 3 } // true
a.any { it > 10 } // false
28 February 2026