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

ruby-changes:37490

From: drbrain <ko1@a...>
Date: Thu, 12 Feb 2015 10:46:47 +0900 (JST)
Subject: [ruby-changes:37490] drbrain:r49571 (trunk): * proc.c (proc_call): Improve Proc#call documentation. Patch by

drbrain	2015-02-12 10:46:33 +0900 (Thu, 12 Feb 2015)

  New Revision: 49571

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

  Log:
    * proc.c (proc_call):  Improve Proc#call documentation.  Patch by
      Hsing-Hui Hsu.  [fix GH-761]

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49570)
+++ ChangeLog	(revision 49571)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Feb 12 10:46:14 2015  Eric Hodel  <drbrain@s...>
+
+	* proc.c (proc_call):  Improve Proc#call documentation.  Patch by
+	  Hsing-Hui Hsu.  [fix GH-761]
+
 Thu Feb 12 04:33:02 2015  Benoit Daloze  <eregontp@g...>
 
 	* compar.c (cmp_equal): no more error hiding for Comparable#==.
Index: proc.c
===================================================================
--- proc.c	(revision 49570)
+++ proc.c	(revision 49571)
@@ -683,20 +683,23 @@ rb_block_clear_env_self(VALUE proc) https://github.com/ruby/ruby/blob/trunk/proc.c#L683
  *  <i>params</i> using something close to method calling semantics.
  *  Generates a warning if multiple values are passed to a proc that
  *  expects just one (previously this silently converted the parameters
- *  to an array).  Note that prc.() invokes prc.call() with the parameters
- *  given.  It's a syntax sugar to hide "call".
+ *  to an array).  Note that <code>prc.()</code> invokes
+ *  <code>prc.call()</code> with the parameters given.  It's a syntax sugar to
+ *  hide "call".
+ *
+ *  Returns the value of the last expression evaluated in the block. See
+ *  also Proc#yield.
+ *
+ *     a_proc = Proc.new { |scalar, *values| values.collect { |value| value*scalar } }
+ *     a_proc.call(9, 1, 2, 3)   #=> [9, 18, 27]
+ *     a_proc[9, 1, 2, 3]        #=> [9, 18, 27]
+ *     a_proc.(9, 1, 2, 3)       #=> [9, 18, 27]
  *
  *  For procs created using <code>lambda</code> or <code>->()</code> an error
  *  is generated if the wrong number of parameters are passed to a Proc with
  *  multiple parameters.  For procs created using <code>Proc.new</code> or
  *  <code>Kernel.proc</code>, extra parameters are silently discarded.
  *
- *  Returns the value of the last expression evaluated in the block. See
- *  also <code>Proc#yield</code>.
- *
- *     a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
- *     a_proc.call(9, 1, 2, 3)   #=> [9, 18, 27]
- *     a_proc[9, 1, 2, 3]        #=> [9, 18, 27]
  *     a_proc = lambda {|a,b| a}
  *     a_proc.call(1,2,3)
  *

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

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