method
<=>
v2_1_10 -
Show latest stable
-
0 notes -
Class: Object
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180 (0)
- 1_9_3_125 (3)
- 1_9_3_392 (0)
- 2_1_10 (38)
- 2_2_9 (9)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
<=>(p1)
public
Returns 0 if obj and other are the same object or obj == other, otherwise nil.
The <=> is used by various methods to compare objects, for example Enumerable#sort, Enumerable#max etc.
Your implementation of <=> should return one of the following values: -1, 0, 1 or nil. -1 means self is smaller than other. 0 means self is equal to other. 1 means self is bigger than other. Nil means the two values could not be compared.
When you define <=>, you can include Comparable to gain the methods <=, <,