概要
Numeric#<=> other -> bool
詳細
self と other を比較し、
同じなら 0
self が小さければ -1
self が大きければ 1
比較できなければ nil
を返却します。
サンプルコード
p 1 <=> 0 p 1 <=> 1 p 1 <=> 2 p 1 <=> 'a'
出力
1 0 -1 nil
Numeric#<=> other -> bool
self と other を比較し、
同じなら 0
self が小さければ -1
self が大きければ 1
比較できなければ nil
を返却します。
p 1 <=> 0 p 1 <=> 1 p 1 <=> 2 p 1 <=> 'a'
1 0 -1 nil