Sha256: ad67331cf77cabdf8e4f03ba63e292d9da7baf20971398d382842f504dd31df4

Contents?: true

Size: 415 Bytes

Versions: 26

Compression:

Stored size: 415 Bytes

Contents

unless ([1].shift(1) rescue false)
  class Array
    require 'backports/tools'

    def shift_with_optional_argument(n = Backports::Undefined)
      return shift_without_optional_argument if n == Backports::Undefined
      n = Backports.coerce_to_int(n)
      raise ArgumentError, "negative array size" if n < 0
      slice!(0, n)
    end
    Backports.alias_method_chain self, :shift, :optional_argument
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
backports-3.3.2 lib/backports/1.8.7/array/shift.rb
backports-3.3.1 lib/backports/1.8.7/array/shift.rb
backports-3.3.0 lib/backports/1.8.7/array/shift.rb
backports-3.2.0 lib/backports/1.8.7/array/shift.rb
backports-3.1.1 lib/backports/1.8.7/array/shift.rb
backports-3.1.0 lib/backports/1.8.7/array/shift.rb