Method: Array#drop

Defined in:
lib/ruby/jruby_hack.rb

#drop(n) ⇒ Array

Select all elements except the first n ones.

Examples:

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

Returns:

Raises:

  • (ArgumentError)


71
72
73
74
# File 'lib/ruby/jruby_hack.rb', line 71

def drop(n)
  raise ArgumentError, "n cannot be negative" if n < 0
  slice(n..-1) or []
end