aboutsummaryrefslogtreecommitdiffstats
path: root/proc.c
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-12 01:46:33 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-12 01:46:33 +0000
commit678ae5d17f0345e2a9ed5a96f142ff432993acfc (patch)
tree003fcf58c6c7a0ce68874142c6f73332d2db5715 /proc.c
parenta1992e25b91d77866cd32f4b16fb666f5e89adf5 (diff)
downloadruby-678ae5d17f0345e2a9ed5a96f142ff432993acfc.tar.gz
* proc.c (proc_call): Improve Proc#call documentation. Patch by
Hsing-Hui Hsu. [fix GH-761] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/proc.c b/proc.c
index 48d7dcb490..d5ac0e8998 100644
--- a/proc.c
+++ b/proc.c
@@ -683,20 +683,23 @@ rb_block_clear_env_self(VALUE proc)
* <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)
*