Mega Code Archive

 
Categories / Ruby / Language Basics
 

Comparable module uses the = operator on the class that includes it

<=> returns -1 if the supplied parameter is higher than the object's value,              0 if they are equal, or              1 if the object's value is higher than the parameter. puts 1 <=> 2 puts 1 <=> 1 puts 2 <=> 1