%dw 2.0
import * from dw::core::Arrays
output application/json
---
{ "results" : [
"ok" : [
[1,2,3] some (($ mod 2) == 0),
[1,2,3] some ((nextNum) -> (nextNum mod 2) == 0),
[1,2,3] some (($ mod 2) == 1),
[1,2,3,4,5,6,7,8] some (log('should stop at 2 ==', $) == 2),
[1,2,3] some ($ == 1),
[1,1,1] some ($ == 1),
[1] some ($ == 1)
],
"err" : [
[1,2,3] some ($ == 100),
[1] some ($ == 2)
]
]
}
some
some<T>(list: Array<T>, condition: (T) -> Boolean): Boolean
Returns true if at least one element in the array matches the specified condition.
The function stops iterating after the first element that matches the condition is found.
Parameters
| Name | Description |
|---|---|
|
The input array. |
|
A condition (or expression) used to match elements in the array. |
Example
This example applies a variety of expressions to elements of several input arrays.
The $ in the condition is the default parameter for the current element of the
array that the condition evaluates.
Note that you can replace the default $ parameter with a lambda expression that
contains a named parameter for the current array element.



