S
Suraj Kurapati
Hello,
I'm trying to make two keys equivalent by having their #hash method
produce the same result. But this does not seem to work:
irb(main):001:0> class K; def hash; 90; end; end
=> nil
irb(main):002:0> h = {}
=> {}
irb(main):003:0> h[K.new] = 1
=> 1
irb(main):004:0> h.key? K.new # <---- I want this to return true!
=> false
What am I missing?
Thanks for your consideration.
I'm trying to make two keys equivalent by having their #hash method
produce the same result. But this does not seem to work:
irb(main):001:0> class K; def hash; 90; end; end
=> nil
irb(main):002:0> h = {}
=> {}
irb(main):003:0> h[K.new] = 1
=> 1
irb(main):004:0> h.key? K.new # <---- I want this to return true!
=> false
What am I missing?
Thanks for your consideration.