dropRight(_ n: Int = 1) -> [Int]

Creates a new sliced array with n elements dropped from the end.

Parameters

  • n: The number of elements to drop. default to 1.

Returns

Returns the new sliced array.

[1,2,3,4,5].dropRight()
// -> [1,2,3,4]
[1,2,3,4,5].dropRight(2)
// -> [1,2,3]