Thursday, 18 December 2008

<=>

<=> is spaceship operator of Ruby. This is general purpose comparison operator. It compares two values and returns -1, 0, +1 depending on whether value1 is less then, equal or grater than value2.
value1 <=> value2 => -1 : if value1 < value2
   0 : if value1 = value2 
 +1 : if value1 > value2 

This operator is equivalent to ICompare.Compare( Object x, Object y) methods of .NET library.

No comments:

Post a Comment