[前][次][番号順一覧][スレッド一覧]

ruby-changes:12270

From: tadf <ko1@a...>
Date: Sun, 5 Jul 2009 22:46:25 +0900 (JST)
Subject: [ruby-changes:12270] Ruby:r23961 (trunk): * complex.c (nucomp_s_polar): now arg is optional.

tadf	2009-07-05 22:46:10 +0900 (Sun, 05 Jul 2009)

  New Revision: 23961

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23961

  Log:
    * complex.c (nucomp_s_polar): now arg is optional.

  Modified files:
    trunk/ChangeLog
    trunk/complex.c

Index: complex.c
===================================================================
--- complex.c	(revision 23960)
+++ complex.c	(revision 23961)
@@ -548,13 +548,25 @@
 
 /*
  * call-seq:
- *    Complex.polar(abs, arg)  ->  complex
+ *    Complex.polar(abs[, arg])  ->  complex
  *
  * Returns a complex object which denotes the given polar form.
  */
 static VALUE
-nucomp_s_polar(VALUE klass, VALUE abs, VALUE arg)
+nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
 {
+    VALUE abs, arg;
+
+    switch (rb_scan_args(argc, argv, "11", &abs, &arg)) {
+      case 1:
+	nucomp_real_check(abs);
+	arg = ZERO;
+	break;
+      default:
+	nucomp_real_check(abs);
+	nucomp_real_check(arg);
+	break;
+    }
     return f_complex_polar(klass, abs, arg);
 }
 
@@ -1260,7 +1272,7 @@
 VALUE
 rb_complex_polar(VALUE x, VALUE y)
 {
-    return nucomp_s_polar(rb_cComplex, x, y);
+    return f_complex_polar(rb_cComplex, x, y);
 }
 
 static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
@@ -1840,7 +1852,7 @@
 
     rb_define_singleton_method(rb_cComplex, "rectangular", nucomp_s_new, -1);
     rb_define_singleton_method(rb_cComplex, "rect", nucomp_s_new, -1);
-    rb_define_singleton_method(rb_cComplex, "polar", nucomp_s_polar, 2);
+    rb_define_singleton_method(rb_cComplex, "polar", nucomp_s_polar, -1);
 
     rb_define_global_function("Complex", nucomp_f_complex, -1);
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23960)
+++ ChangeLog	(revision 23961)
@@ -1,3 +1,7 @@
+Sun Jul  5 22:43:13 2009  Tadayoshi Funaba  <tadf@d...>
+
+	* complex.c (nucomp_s_polar): now arg is optional.
+
 Sun Jul  5 20:40:35 2009  Tadayoshi Funaba  <tadf@d...>
 
 	* complex.c (float_arg): returns PI for -0.0.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]