BoxSetSome
Test whether at least one element of a Set satisfies a predicate.
Iteration short-circuits on the first element for which the predicate returns true. Returns false for an empty Set. The predicate receives the element value, its 1-based ordinal position, and the Set itself.
Method Signature
BoxSetSome(set=[set], callback=[function:Predicate])Arguments
Argument
Type
Required
Description
Default
set
set
true
The set to test.
callback
function:Predicate
true
Predicate invoked for each element. Receives {@code (value, ordinal, set)}. Short-circuits on the first {@code true} result.
Examples
Test that at least one element satisfies a predicate
Returns true on the first match.
s = [ 1, 2, 3, 4 ].toSet();
writeOutput( s.some( ( Any v ) => v > 3 ) );
Result: true
Returns false when nothing matches
Result: false
Using the any alias
any is an alias for some.
Result: true
Related
Last updated
Was this helpful?
