%dw 2.0
import * from dw::core::Arrays
output application/json
var arr = [0,1,3,2,1]
---
arr dropWhile $ < 3
dropWhile
dropWhile<T>(array: Array<T>, condition: (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 version 2.2.0.
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
.