From: Run Paint Run Run Date: 2009-06-15T11:25:53+09:00 Subject: [ruby-core:23859] [Bug #1636] Rational#coerce(Rational) Raises TypeError Bug #1636: Rational#coerce(Rational) Raises TypeError http://redmine.ruby-lang.org/issues/show/1636 Author: Run Paint Run Run Status: Open, Priority: Normal Category: core ruby -v: ruby 1.9.2dev (2009-06-14 trunk 23689) [i686-linux] 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 `
' 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. ---------------------------------------- http://redmine.ruby-lang.org