#slice
Returns the part of an array that falls within the provided range.
#slice(array, range)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
array |
path | array |
The source array. |
range |
range |
A range such as 2..4, ..3 or ^3... |
Returns
Section titled “Returns”array
@array[range]is shorthand for#slice(@array, range). See indexing and slicing.
Examples
Section titled “Examples”Middle of an array
Section titled “Middle of an array”{ "numbers": [ 1, 9, 3, 2, 6 ]}{ "result": "#slice($.numbers, 2..4)"}{ "result": [ 3, 2 ]}Related
Section titled “Related”#substring · #take · #skip
