Docs Home
/
KCL Standard Library
/
Functions
/
slice

sliceFunction in std::array

Get a subarray from start (inclusive) to end (exclusive).

Returns a new array containing the elements in the requested range. Negative indexes count from the end of the array, so -1 is the last element, -2 is the second-to-last element, and so on.

If start is omitted, it defaults to 0. If end is omitted, it defaults to the length of the array.

It is an error to omit both start and end. Arrays are immutable, so there's no need to copy the whole array.

Arguments

NameTypeDescriptionRequired
array[any]The array to slice.Yes
startnumber(_)The starting index (inclusive). Defaults to 0.No
endnumber(_)The ending index (exclusive). Defaults to the array length.No

Returns

[any]

Examples

Found a typo?
Zookeeper is here!
You guide the design. Zookeeper does the work.