Method: String#drop

Defined in:
lib/ruby/jruby_hack.rb

#drop(n) ⇒ String

Return the string with n characters removed from the front

Examples:

"abc".drop(0)   #=> "abc"
"abc".drop(2)   #=> "c"

Parameters:

  • n (Integer)

    number of characters to drop (‘n > 0`)

Returns:

Raises:

  • (ArgumentError)


457
458
459
460
# File 'lib/ruby/jruby_hack.rb', line 457

def drop(n)
  raise ArgumentError, "n must be positive" if n < 0
  (length >= n) ? self[n..-1] : ""
end