Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4619

What is the effect of hash and eq implementation in Ruby

$
0
0
class A  def hash    12  end  def ==(other)    true  endendx = {}a = A.newb = A.newx[a] = "Hello"x[b] = "World"puts x

This is printing:
{#<A:0x000055d1f3985c68>=>"Hello", #<A:0x000055d1f3985830>=>"World"}

I expected replacement, not happening, why?


Viewing all articles
Browse latest Browse all 4619

Trending Articles