Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > rationalライブラリ > Rationalクラス > coerce

instance method Rational#coerce

coerce(other) -> Array

自身と other が同じクラスになるよう、自身か other を変換し [other, self] という 配列にして返します。

[PARAM] other:
比較または変換するオブジェクト

例:

Rational(1).coerce(2)   # => [Rational(2, 1), Rational(1, 1)]
Rational(1).coerce(2.2) # => [2.2, 1.0]
class Rational