self <=> other -> -1 | 0 | 1 | nilRuby 2.4.0 から[permalink][rdoc][edit]-
selfとotherを比較して、selfが大きい時に1、等しい時に0、小さい時に-1、比較できない時にnilを返します。- [PARAM]
other: - 比較対象の数値
- [RETURN]
-
-1か0か1かnilのいずれか
p 1 <=> 2 # => -1 p 1 <=> 1 # => 0 p 2 <=> 1 # => 1 p 2 <=> '' # => nil - [PARAM]