# Hash#compare\_by\_identity breaks commutativity of Hash#==

**URL:** <https://www.ruby-forum.com/t/hash-compare-by-identity-breaks-commutativity-of-hash/130896>\
**Category:** Development\
**Created:** [March 4, 2008, 10:43am UTC](https://www.ruby-forum.com/t/hash-compare-by-identity-breaks-commutativity-of-hash/130896 "2008-03-04T10:43:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [March 4, 2008, 10:43am UTC](https://www.ruby-forum.com/t/hash-compare-by-identity-breaks-commutativity-of-hash/130896/1 "2008-03-04T10:43:12Z")

</div>

e$B0J2\<$N$h$&$K!“e(Bh1 == h2 e$B$G$J$$$N$Ke(B h2 == h1  
e$B$H$$$&$3$H$K$J$ke(B  
e$B$3$H$,$”$j$^$9!#e(B

% ./ruby -ve ’  
h1 = {“a” =\> 0}  
h2 = {“a” =\> 0}  
h2.compare\_by\_identity  
p h1 == h2  
p h2 == h1  
’  
ruby 1.9.0 (2008-03-04 revision 15686) [i686-linux]  
false  
true
