Another similarity is for objects used as keys in maps (hashes). If you want to customize their behavior, in both Ruby and Java will have to override
Object.hashCode(). And that would be it with the similarities.
In Ruby world,
Object?== are named equivalence. I haven’t been able to find out the reasons for having both
Object?== and the only example I have found is the following:
2.eql? 2.0 => false 2 == 2.0 => true
Ruby has another equality method
Object#=== and this one is used only in case statements.
- The Ruby Way
- Programming Ruby- The Pragmatic Programmer’s Guide 2nd Ed (known also as the ~PickAxe book)
- comparing objects
- which method do I have to override?
- hash and ==
- equivalence relation