summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-23 11:42:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-23 11:42:50 +0000
commita93ce3e1b87bea671fc4f47a19060faf2e23789f (patch)
treee0b7d12455d68c2d0bdbce996ef14448e467c638 /proc.c
parent16f886328a03b887a71131a8fc740eb18a42898e (diff)
proc.c: [DOC] refine proc-compistion examples [ci skip]
* proc.c: [DOC] refine proc-compistion examples by using same Proc/Method and different composition orders. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/proc.c b/proc.c
index 1999e285eb..ca111507c7 100644
--- a/proc.c
+++ b/proc.c
@@ -3072,10 +3072,9 @@ compose(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
* The returned proc takes a variable number of arguments, calls <i>g</i> with them
* then calls this proc with the result.
*
- * f = proc {|x| x * 2 }
- * g = proc {|x, y| x + y }
- * h = f << g
- * p h.call(1, 2) #=> 6
+ * f = proc {|x| x * x }
+ * g = proc {|x| x + x }
+ * p (f << g).call(2) #=> 16
*/
static VALUE
proc_compose_to_left(VALUE self, VALUE g)
@@ -3106,10 +3105,9 @@ proc_compose_to_left(VALUE self, VALUE g)
* The returned proc takes a variable number of arguments, calls <i>g</i> with them
* then calls this proc with the result.
*
- * f = proc {|x, y| x + y }
- * g = proc {|x| x * 2 }
- * h = f >> g
- * p h.call(1, 2) #=> 6
+ * f = proc {|x| x * x }
+ * g = proc {|x| x + x }
+ * p (f >> g).call(2) #=> 8
*/
static VALUE
proc_compose_to_right(VALUE self, VALUE g)
@@ -3141,13 +3139,12 @@ proc_compose_to_right(VALUE self, VALUE g)
* then calls this method with the result.
*
* def f(x)
- * x * 2
+ * x * x
* end
*
* f = self.method(:f)
- * g = proc {|x, y| x + y }
- * h = f << g
- * p h.call(1, 2) #=> 6
+ * g = proc {|x| x + x }
+ * p (f << g).call(2) #=> 16
*/
static VALUE
rb_method_compose_to_left(VALUE self, VALUE g)
@@ -3164,14 +3161,13 @@ rb_method_compose_to_left(VALUE self, VALUE g)
* The returned proc takes a variable number of arguments, calls <i>g</i> with them
* then calls this method with the result.
*
- * def f(x, y)
- * x + y
+ * def f(x)
+ * x * x
* end
*
* f = self.method(:f)
- * g = proc {|x| x * 2 }
- * h = f >> g
- * p h.call(1, 2) #=> 6
+ * g = proc {|x| x + x }
+ * p (f >> g).call(2) #=> 8
*/
static VALUE
rb_method_compose_to_right(VALUE self, VALUE g)