summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-19 22:23:15 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-19 22:23:15 +0000
commit7c4d0468df37da40cbcd178070b288dd535bc72e (patch)
treeae1d0e014aad43e4ad046c11112a7528c7267122
parentcca61dafe8f2799994a57f067ea10472992c13b5 (diff)
* complex.c: Examples for Complex Documentation.
Patch by Robin Dupret. Fixes #184 on github. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--complex.c20
2 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e73172..d3d5603 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Sep 20 07:20:00 2012 Zachary Scott <zzak@ruby-lang.org>
+
+ * complex.c: Examples for Complex Documentation.
+ Patch by Robin Dupret.
+ Fixes #184 on github.
+
Thu Sep 20 07:15:00 2012 Zachary Scott <zzak@ruby-lang.org>
* ext/ripper/lib/ripper.rb: Documentation for Ripper.
diff --git a/complex.c b/complex.c
index 230f713..a1ec5d5 100644
--- a/complex.c
+++ b/complex.c
@@ -440,6 +440,10 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
* Complex.rectangular(real[, imag]) -> complex
*
* Returns a complex object which denotes the given rectangular form.
+ *
+ * For example:
+ * Complex.rect(12, 2) # => (12+2i)
+ * Complex.rect(0, 17) # => (0+17i)
*/
static VALUE
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
@@ -679,7 +683,11 @@ f_addsub(VALUE self, VALUE other,
* call-seq:
* cmp + numeric -> complex
*
- * Performs addition.
+ * Performs addition on the first member of the Complex.
+ *
+ * Complex(5, 2) + 3 # => (8+2i)
+ * Complex(11, 3) + 4 # => (15+3i)
+ *
*/
static VALUE
nucomp_add(VALUE self, VALUE other)
@@ -691,7 +699,10 @@ nucomp_add(VALUE self, VALUE other)
* call-seq:
* cmp - numeric -> complex
*
- * Performs subtraction.
+ * Performs subtraction on the first member of the Complex.
+ *
+ * Complex(33, 12) - 10 # => (23+12i)
+ * Complex(12.4, 3.5) - 5 # => (7.4+3.5i)
*/
static VALUE
nucomp_sub(VALUE self, VALUE other)
@@ -703,7 +714,10 @@ nucomp_sub(VALUE self, VALUE other)
* call-seq:
* cmp * numeric -> complex
*
- * Performs multiplication.
+ * Performs multiplication on the two members.
+ *
+ * Complex(78, 58) * 10 # => (780+580i)
+ * Complex(5.6, 3.4) * 10 # => (56+34i)
*/
static VALUE
nucomp_mul(VALUE self, VALUE other)