%dw 2.0
import * from dw::core::Arrays
output application/json
var arr = [0,1,3,2,1]
---
arr dropWhile $ < 3
dropWhile
dropWhile(Array<T>, (item: T) -> Boolean): Array<T>
Drops elements from the array while the condition is met but stops the selection process when it reaches an element that fails to satisfy the condition.
Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later.
Parameters
Name | Description |
---|---|
|
The array of elements. |
|
The condition (or expression) used to match an element in the array. |
Example
This example returns an array that omits elements that are less than or equal to 2
.
The last two elements (2
and 1
) are included in the output array because the
function stops dropping elements when it reaches the 3
, which is greater than 2
.