slice(start: Int, end: Int? = nil) -> [Element]

Return an array by slicing from start up to, but not including, end.

Parameters

  • start: The start position.
  • end: The end position. nil by default

Returns

The sliced array

[1,2,3,4,5].slice(start: 2, end: 5)
// -> [3,4,5]