Ruby 4.0 リファレンスマニュアル

instance method Rational#/

self / other -> Rational | Float[permalink][rdoc][edit]
quo(other) -> Rational | FloatRuby 1.9.3 から

商を計算します。

[PARAM] other:
self を割る数

otherFloat を指定した場合は、計算結果を Float で返します。

r = Rational(3, 4)
p r / 2              # => (3/8)
p r / 2.0            # => 0.375
p r / 0.5            # => 1.5
p r / Rational(1, 2) # => (3/2)
r / 0                # ~> ZeroDivisionError
[EXCEPTION] ZeroDivisionError:
other0 の時に発生します。

[SEE_ALSO] Numeric#quo