I have a wrapper class around some objects that I want to use as keys in Hash. Wrapped and unfolded objects must map to the same key.
A simple example would be the following:
class A
attr_reader :x
def initialize(inner)
@inner=inner
end
def x; @inner.x; end
def ==(other)
@inner.x==other.x
end
end
a = A.new(o)
b = A.new(o)
h = {a=>5}
p h[a]
p h[b]
p h[o]
I tried ==, ===, eq? and the hash is all to no avail.
source
share