Actions
Bug #9381
closed2.1.0 Regression. Hash lookup with #hash and #eql?
Description
Ruby 2.1.0 won't fetch objects when the lookup key overrides #hash
and #eql?
.
This is a regression as it works as expected in ruby 1.8, 1.9 and 2.0.
class Wrapper
def initialize(obj)
@obj = obj
end
def method_missing(symbol, *args, &block)
@obj.__send__(symbol, *args, &block)
end
def hash
@obj.hash
end
def eql?(other)
@obj.eql?(other)
end
end
hash = { 5 => "LOOKUP SUCCEEDED" }
# Prints "LOOKUP SUCCEEDED" on RUBY < 2.1.0. Fails on RUBY 2.1.0.
p hash[Wrapper.new(5)]
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0