Implementing Equality in Ruby
摘要
Ruby is one of the few programming languages that get equality right. I often play around with other languages, but keep coming back to Ruby. This is largely because Ruby’s implementation of equality is so nice.
Nonetheless, equality in Ruby isn't straightforward. There is #==, #eql?, #equal?, #===, and more. Even if you’re familiar with how to use them, implementing them can be a whole other story.
Let's walk through all forms of equality in Ruby and how to implement them.
欢迎在评论区写下你对这篇文章的看法。