O'Reilly logo

Eloquent Ruby by Russ Olsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Create Classes That Understand Equality

Have you ever noticed that it’s smallest words that have the longest entries in the dictionary? My copy of Webster’s dismisses a ten-dollar word like cryptozoology with a single three-line definition.1 In contrast, although we all would like to think that we know right from wrong, the word right consumes almost two pages and sports no less than 58 separate definitions. Fortunately, software engineers don’t usually have to wrestle with the finer points of moral philosophy while coding. We do, however, have something almost as difficult: We have object equality. Like right and wrong, object equality is a much tougher question than it appears on first blush.

Since understanding object equality ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required