Ruby 1.9.3 リファレンスマニュアル
> ライブラリ一覧
> 組み込みライブラリ
> Rationalクラス
> +
instance method Rational#+
self + other -> Rational | Float
-
和を計算します。
- [PARAM] other:
-
自身に足す数
other に Float を指定した場合は、計算結果を Float で返しま
す。
例:
r = Rational(3, 4)
r + Rational(1, 2) # => (5/4)
r + 1 # => (7/4)
r + 0.5 # => 1.25