Skip to content

Commit 7c4d046

Browse files
author
zzak
committed
* 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
1 parent cca61da commit 7c4d046

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Thu Sep 20 07:20:00 2012 Zachary Scott <[email protected]>
2+
3+
* complex.c: Examples for Complex Documentation.
4+
Patch by Robin Dupret.
5+
Fixes #184 on github.
6+
17
Thu Sep 20 07:15:00 2012 Zachary Scott <[email protected]>
28

39
* ext/ripper/lib/ripper.rb: Documentation for Ripper.

complex.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
440440
* Complex.rectangular(real[, imag]) -> complex
441441
*
442442
* Returns a complex object which denotes the given rectangular form.
443+
*
444+
* For example:
445+
* Complex.rect(12, 2) # => (12+2i)
446+
* Complex.rect(0, 17) # => (0+17i)
443447
*/
444448
static VALUE
445449
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
@@ -679,7 +683,11 @@ f_addsub(VALUE self, VALUE other,
679683
* call-seq:
680684
* cmp + numeric -> complex
681685
*
682-
* Performs addition.
686+
* Performs addition on the first member of the Complex.
687+
*
688+
* Complex(5, 2) + 3 # => (8+2i)
689+
* Complex(11, 3) + 4 # => (15+3i)
690+
*
683691
*/
684692
static VALUE
685693
nucomp_add(VALUE self, VALUE other)
@@ -691,7 +699,10 @@ nucomp_add(VALUE self, VALUE other)
691699
* call-seq:
692700
* cmp - numeric -> complex
693701
*
694-
* Performs subtraction.
702+
* Performs subtraction on the first member of the Complex.
703+
*
704+
* Complex(33, 12) - 10 # => (23+12i)
705+
* Complex(12.4, 3.5) - 5 # => (7.4+3.5i)
695706
*/
696707
static VALUE
697708
nucomp_sub(VALUE self, VALUE other)
@@ -703,7 +714,10 @@ nucomp_sub(VALUE self, VALUE other)
703714
* call-seq:
704715
* cmp * numeric -> complex
705716
*
706-
* Performs multiplication.
717+
* Performs multiplication on the two members.
718+
*
719+
* Complex(78, 58) * 10 # => (780+580i)
720+
* Complex(5.6, 3.4) * 10 # => (56+34i)
707721
*/
708722
static VALUE
709723
nucomp_mul(VALUE self, VALUE other)

0 commit comments

Comments
 (0)