Sha256: 78e4cf727c63fedb1d63c76d00675e8f4c4325223a46a57c1a3533f5fcdfed29
Contents?: true
Size: 526 Bytes
Versions: 47
Compression:
Stored size: 526 Bytes
Contents
unless ([1].pop(1) rescue false) require 'backports/tools/alias_method_chain' require 'backports/tools/arguments' class Array def pop_with_optional_argument(n = Backports::Undefined) return pop_without_optional_argument if n == Backports::Undefined n = Backports.coerce_to_int(n) raise ArgumentError, "negative array size" if n < 0 first = size - n first = 0 if first < 0 slice!(first..size).to_a end Backports.alias_method_chain self, :pop, :optional_argument end end
Version data entries
47 entries across 47 versions & 4 rubygems