10 Things Every Java Programmer Should Know About Ruby

Tedious comparison operators

Although all the logic is in the less-than method, all the other comparisons must still be defined.

class Pair
  attr_accessor :first, :second
  # ...

  def <(other)
    (first < other.first) ||
      (first == other.first && second < other.second)
  end
  def >(other)
    other < self
  end
  # Other methods defined in terms of less than:
  #     <=, >=, ==
end