Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Array#drop

array.drop(n) → new_array

Returns a new Array containing all but the first n element of self, where n is a non-negative Integer; does not modify self.

Examples:

Example
a = [0, 1, 2, 3, 4, 5]
a.drop(0) # => [0, 1, 2, 3, 4, 5]
a.drop(1) # => [1, 2, 3, 4, 5]
a.drop(2) # => [2, 3, 4, 5]

Ruby version changes

  1. 3.0
See also #dig #drop_while #difference #each also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0