drop function

List drop (
  1. List array,
  2. [int n = 1]
)

Creates a slice of array with n elements dropped from the beginning.

drop([1, 2, 3])
// => [2,3]

drop([1, 2, 3], 2)
// => [3]

drop([1, 2, 3], 5)
// => []

drop([1, 2, 3], 0)
// => [1, 2, 3]

Implementation

List drop(List array, [int n = 1]) {
  return array.isEmpty ? [] : slice(array, n < 0 ? 0 : n, array.length);
}