Ruby LanguageComparable

Syntax

  • include Comparable
  • implement the space-ship operator (<=>)

Parameters

ParameterDetails
otherThe instance to be compared to self

Remarks

x <=> y should return a negative number if x < y, zero if x == y and a positive number if x > y.

Related Examples

Rectangle comparable by area