summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-21 12:54:06 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-21 12:54:06 +0000
commit4d03af3d9cdedacadc1e967490c9201fec13fc53 (patch)
tree81f252fc070ca764b35b08daf5cb8d1b30cae46a /complex.c
parentc07d295204de26a8926b5c58c2b849022e5db02b (diff)
* complex.c (nucomp_to_c): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/complex.c b/complex.c
index d262e9a..1d61fda 100644
--- a/complex.c
+++ b/complex.c
@@ -1474,6 +1474,21 @@ nucomp_rationalize(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
+ * complex.to_c -> self
+ *
+ * Returns self.
+ *
+ * Complex(2).to_c #=> (2+0i)
+ * Complex(-8, 6).to_c #=> (-8+6i)
+ */
+static VALUE
+nucomp_to_c(VALUE self)
+{
+ return self;
+}
+
+/*
+ * call-seq:
* nil.to_c -> (0+0i)
*
* Returns zero as a complex.
@@ -2178,6 +2193,7 @@ Init_Complex(void)
rb_define_method(rb_cComplex, "to_f", nucomp_to_f, 0);
rb_define_method(rb_cComplex, "to_r", nucomp_to_r, 0);
rb_define_method(rb_cComplex, "rationalize", nucomp_rationalize, -1);
+ rb_define_method(rb_cComplex, "to_c", nucomp_to_c, 0);
rb_define_method(rb_cNilClass, "to_c", nilclass_to_c, 0);
rb_define_method(rb_cNumeric, "to_c", numeric_to_c, 0);