Skip to content
Shopify

Implementing Equality in Ruby - Shopify

May 26, 202218 min read
Opens shopify.engineering
What the post coversAI, from the source post

This post details the nuances of implementing equality in Ruby, covering the `==`, `#eql?`, `#equal?`, and `#===` operators.

  • It explains the distinction between entities (identified by an explicit `id`) and value objects (identified by their attributes), providing code examples for correct implementation of the `==` operator for both.
  • It also discusses type coercion and the properties of a correct equality implementation (reflexivity, symmetry, transitivity), including the rare exception of NaN.
Read the full post on shopify.engineering · 18 min (opens in a new tab)