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

instance method Rational#*

self * other -> Rational | Float[permalink][rdoc][edit]
(Integer) → Rational
(Rational) → Rational
[T < Numeric] (T) → T

selfother を掛けた値(=積)を返します。

Rational オブジェクトを左項とする算術演算子 * はこのメソッドの呼び出しになります。

[PARAM] other:
self に対する乗数

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

r = Rational(3, 4)
p r * 2              # => (3/2)
p r * 4              # => (3/1)
p r * 0.5            # => 0.375
p r * Rational(1, 2) # => (3/8)