self <=> other -> -1 | 0 | 1 | nil[permalink][rdoc][edit](Integer | Rational) → Integer(untyped) → Integer?-
selfをotherと比較し、selfがotherより大きければ1を、等しければ0を、小さければ-1を返します。比較できないときはnilを返します。Rationalオブジェクトを左項とする二項演算子<=>はこのメソッドの呼び出しになります。- [PARAM]
other: - 比較対象
p Rational(2, 3) <=> Rational(2, 3) # => 0 p Rational(5) <=> 5 # => 0 p Rational(2, 3) <=> Rational(1,3) # => 1 p Rational(1, 3) <=> 1 # => -1 p Rational(1, 3) <=> 0.3 # => 1 p Rational(1, 3) <=> nil # => nil - [PARAM]