Contact Free trial Login

slice

slice(Array<T>, Number, Number): Array<T>

Selects the interval of elements that satisfy the condition: from <= indexOf(array) < until

Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later.

Parameters

Name Description

array

The array of elements.

from

The lowest index to include from the array.

until

The lowest index to exclude from the array.

Example

This example returns an array that contains the values of indices 1, 2, and 3 from the input array. It excludes the values of indices 0, 4, and 5.

Source

%dw 2.0
import * from dw::core::Arrays
output application/json
var arr = [0,1,2,3,4,5]
---
slice(arr, 1, 4)

Output

[
  1,
  2,
  3
]

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.