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

ruby-changes:53719

From: nobu <ko1@a...>
Date: Fri, 23 Nov 2018 20:42:56 +0900 (JST)
Subject: [ruby-changes:53719] nobu:r65935 (trunk): proc.c: [DOC] refine proc-compistion examples [ci skip]

nobu	2018-11-23 20:42:50 +0900 (Fri, 23 Nov 2018)

  New Revision: 65935

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65935

  Log:
    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.

  Modified files:
    trunk/proc.c
Index: proc.c
===================================================================
--- proc.c	(revision 65934)
+++ proc.c	(revision 65935)
@@ -3072,10 +3072,9 @@ compose(VALUE dummy, VALUE args, int arg https://github.com/ruby/ruby/blob/trunk/proc.c#L3072
  *  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 https://github.com/ruby/ruby/blob/trunk/proc.c#L3105
  *  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 https://github.com/ruby/ruby/blob/trunk/proc.c#L3139
  *  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, VA https://github.com/ruby/ruby/blob/trunk/proc.c#L3161
  *  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)

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

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