#takeWhile
Returns the leading elements of an array that satisfy a condition.
#takeWhile(array, @x: predicate)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
array |
path | array |
The source array. |
predicate |
lambda |
Returns true to keep taking. |
Returns
Section titled “Returns”array
Examples
Section titled “Examples”Take until a large value
Section titled “Take until a large value”{ "numbers": [ 1, 2, 6, 3 ]}{ "result": "#takeWhile($.numbers, @x: @x < 5)"}{ "result": [ 1, 2 ]}Related
Section titled “Related”#skipWhile · #take · #where
