slice

Summary

Returns a subset of the array beginning at the specified index until the end of the array.

Signatures

Click on a signature to select it and view its documentation.

Usage

public T[] slice(int begin)

Returns

A shallow copy representing the subset of the array beginning at the specified index until the end of the array.

Parameters

begin

Zero-based index to begin extraction from. This argument can be negative to begin the slice from the end of the array.

Description

Returns a shallow copy representing the subset of the array beginning at the specified index until the end of the array.

This method does not mutate the array.

Examples

Slicing from the beginning of the array
1
2
3
import System;
 
[ 1, 2, 3, 4, 5 ].slice(1); // [ 2, 3, 4, 5 ]
Slicing from the end of the array
1
2
3
import System;
 
[ 1, 2, 3, 4, 5 ].slice(-2); // [ 4, 5 ]

Share

HTML | BBCode | Direct Link