Created
May 23, 2011 01:01
-
-
Save ryanlecompte/986065 to your computer and use it in GitHub Desktop.
Hash
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
ruby-1.9.2-head :001 > class C | |
ruby-1.9.2-head :002?> def ==(o) | |
ruby-1.9.2-head :003?> puts "==(0)" | |
ruby-1.9.2-head :004?> super | |
ruby-1.9.2-head :005?> end | |
ruby-1.9.2-head :006?> def eql?(o) | |
ruby-1.9.2-head :007?> puts "eql?(o)" | |
ruby-1.9.2-head :008?> super | |
ruby-1.9.2-head :009?> end | |
ruby-1.9.2-head :010?> def hash | |
ruby-1.9.2-head :011?> puts "hash" | |
ruby-1.9.2-head :012?> 1 | |
ruby-1.9.2-head :013?> end | |
ruby-1.9.2-head :014?> end | |
=> nil | |
ruby-1.9.2-head :015 > h = {} | |
=> {} | |
ruby-1.9.2-head :016 > h[C.new] = 'blah' | |
hash | |
=> "blah" | |
ruby-1.9.2-head :017 > h[C.new] | |
hash | |
eql?(o) | |
=> nil | |
ruby-1.9.2-head :018 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment