instance method Rational#+
self + other -> Rational | Float
-
和を計算します。
- [PARAM] other:
- 自身に足す数
other に Float を指定した場合は、計算結果を Float で返しま す。
例:
Rational(3, 4) + 2 # => Rational(11, 4) Rational(3, 4) + Rational(2, 1) # => Rational(11, 4) Rational(3, 4) + 2.0 # => 2.75
class Rational