diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-21 10:34:14 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-06-21 10:34:14 +0000 |
| commit | 75a66fa96c9976b337ccaa73f4b7260a88eb0617 (patch) | |
| tree | 3eae79691a8540c4586a4bac763a597a171434a7 /rational.c | |
| parent | 8344fa5eff92516fe15eb4152aea883fd5da5e1f (diff) | |
merges r23727 from trunk into ruby_1_9_1.
--
* rational.c (nurat_coerce): accepts Complex when the imag is
exact zero.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'rational.c')
| -rw-r--r-- | rational.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rational.c b/rational.c index 6d31c542a..6e35573eb 100644 --- a/rational.c +++ b/rational.c @@ -904,6 +904,10 @@ nurat_coerce(VALUE self, VALUE other) return rb_assoc_new(other, f_to_f(self)); case T_RATIONAL: return rb_assoc_new(other, self); + case T_COMPLEX: + if (k_exact_p(RCOMPLEX(other)->imag) && f_zero_p(RCOMPLEX(other)->imag)) + return rb_assoc_new(f_rational_new_bang1 + (CLASS_OF(self), RCOMPLEX(other)->real), self); } rb_raise(rb_eTypeError, "%s can't be coerced into %s", |
