summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-16 23:17:17 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-06-16 23:17:17 +0000
commitad522685814acd682765d4ca81e2e6fb35595471 (patch)
treec03667f6ee8f999e8a60b23453e7b12e043c9880 /complex.c
parentcde491005e3776b73c25cb7ec45e8750f7ade770 (diff)
* complex.c (nucomp_coerce): accepts Complex instances.
* rational.c (nurat_coerce): accepts Rational instances. [ruby-core:23859] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/complex.c b/complex.c
index df190d85ac..0e9a17b7a6 100644
--- a/complex.c
+++ b/complex.c
@@ -747,6 +747,8 @@ nucomp_coerce(VALUE self, VALUE other)
{
if (k_numeric_p(other) && f_real_p(other))
return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self);
+ if (TYPE(other) == T_COMPLEX)
+ return rb_assoc_new(other, self);
rb_raise(rb_eTypeError, "%s can't be coerced into %s",
rb_obj_classname(other), rb_obj_classname(self));