Actions
Bug #1636
closedRational#coerce(Rational) Raises TypeError
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-06-14 trunk 23689) [i686-linux]
Backport:
Description
=begin
On 1.9.2 trunk:
>> Rational(2).coerce(Rational(2))
TypeError: Rational can't be coerced into Rational
from (irb):1:in `coerce'
from (irb):1
from /usr/local/bin/irb:12:in `<main>'
However:
>> 2.coerce(2)
=> [2, 2]
>> 2.2.coerce(2.2)
=> [2.2, 2.2]
Indeed, the documentation for Numeric#coerce states "If aNumeric is the same type as num, returns an array containing aNumeric and num."
It also works on 1.8.7:
>> Rational(1).coerce(Rational(1)
=> [Rational(1, 1), Rational(1, 1)]
I suspect this should be special cased, for consistency if nothing else.
=end
Updated by tadf (tadayoshi funaba) over 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23718.
=end
Actions
Like0
Like0