Last active
August 29, 2015 13:57
-
-
Save newmana/9749396 to your computer and use it in GitHub Desktop.
Hash uses eql? not ==
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.1.1 :001 > {2 => "foo", 2.0 => "bar"} | |
=> {2=>"foo", 2.0=>"bar"} | |
2.1.1 :002 > 2 == 2.0 | |
=> true | |
2.1.1 :003 > 2.eql?(2.0) | |
=> false |
The documentation for Hash keys:
http://www.ruby-doc.org/core-2.1.1/Hash.html#class-Hash-label-Hash+Keys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the C code they use a macro EQUAL. I didn't look too closely but it could be calling the eql? method. On the equ? vs == method check out this: http://blog.elpassion.com/ruby-gotchas/