![]() |
sponsored links |
|
|
sponsored links
|
|
|
2
14th April 04:31
External User
Posts: 1
|
You'll need to define #hash and #eql? as well.
If its a wrapper object, I usually pass through to the wrapper. If its a composite object something like ^ ing all the components hashes together works. Its not hard enough that you need an extra library. You'll want to define #<=> and include Comparable if you want to sort your objects sensibly. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 |
|
|
5
23rd April 04:43
External User
Posts: 1
|
#eql? is only used by Hash to determine if two keys (#hash) collide.
Usually it just calls #==. if object1.hash == object2.hash and object1.eql? object2 then # both objects occupy the same slot in a Hash else # the objects occupy different slots in a Hash end -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 |
|
|