Enumerable#drop

Updated March 31, 2026 · Enumerable
ruby enumerable drop stdlib

Enumerable#drop

Drops (skips) the first n elements from an enumerator and returns the rest as an array.

Signature

drop(n) -> Array

Basic Usage

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

drop counts from the start and returns everything after the first n elements. If n is zero, it returns a copy of the original array. If n exceeds the collection size, it returns an empty array — no error is raised.

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

[1, 2, 3].drop(10)
# => []

How It Differs From take

take and drop are complementary:

  • take(n) keeps the first n elements
  • drop(n) removes the first n elements and returns the rest
queue = [10, 20, 30, 40, 50]

queue.take(3)
# => [10, 20, 30]

queue.drop(3)
# => [40, 50]

You can combine them to split a collection into head and tail:

head, *tail = [1, 2, 3, 4, 5].partition.with_index { |_, i| i < 2 }
head
# => [[1, 2]]
tail
# => [[3, 4, 5]]

# Or with drop and take:
rest = [1, 2, 3, 4, 5].drop(2)
rest.first(2)  # same as take(2)
# => [3, 4]

How It Differs From drop_while

  • drop skips elements by position (fixed count)
  • drop_while skips elements by condition (until the block returns false)
# drop skips exactly 2 elements regardless of their values
[1, 99, 2, 3].drop(2)
# => [2, 3]

# drop_while skips until a value fails the condition
[1, 99, 2, 3].drop_while { |x| x < 10 }
# => [99, 2, 3]

Practical Examples

Skip a header row

rows = [
  ["Name", "Score"],
  ["Alice", 95],
  ["Bob", 87],
  ["Carol", 92]
]

data_rows = rows.drop(1)
# => [["Alice", 95], ["Bob", 87], ["Carol", 92]]

Skip calibration readings

readings = [0.0, 0.0, 0.1, 0.2, 0.5, 1.2, 1.8]
calibrated = readings.drop(3)
# => [0.2, 0.5, 1.2, 1.8]

Head and tail pattern with take and drop

def split_head_tail(arr, n)
  head = arr.take(n)
  tail = arr.drop(n)
  [head, tail]
end

split_head_tail([1, 2, 3, 4, 5], 2)
# => [[1, 2], [3, 4, 5]]

Return Value

drop always returns an Array, even if the original enumerator is something else like a Range or a Hash (which gets enumerated to its pairs):

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

{a: 1, b: 2, c: 3}.drop(1)
# => [[:b, 2], [:c, 3]]

Edge Cases

InputResult
drop(0)Full copy of the collection
drop(size)Empty array []
drop(n > size)Empty array []
drop on emptyEmpty array []

See Also