Sha256: 1aa2a1a35b0b36325980db9e2a458d05866d1186dca45088171161684b0970e8
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
class Hash # Standard in Ruby 1.8.8. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html] class << self def try_convert(x) Backports.try_convert(x, Hash, :to_hash) end unless method_defined? :try_convert end # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html] def default_proc=(proc) if proc == nil # nil accepted in Ruby 2.0 self.default = nil self else replace(Hash.new(&Backports.coerce_to(proc, Proc, :to_proc)).merge!(self)) end end unless method_defined? :default_proc= # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html] def assoc(key) val = fetch(key) do return find do |k, v| [k, v] if k == key end end [key, val] end unless method_defined? :assoc # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Hash.html] def rassoc(value) k = key(value) v = fetch(k){return nil} [k, fetch(k)] if k || v == value end unless method_defined? :rassoc end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
backports-3.0.3 | lib/backports/1.9.1/hash.rb |
backports-3.0.2 | lib/backports/1.9.1/hash.rb |
backports-3.0.1 | lib/backports/1.9.1/hash.rb |
backports-3.0.0 | lib/backports/1.9.1/hash.rb |