* proc.c (proc_call): Update documentation to match argument handling

of proc/Proc.new/lambda/->()


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2011-10-03 23:16:11 +00:00
parent b7ea625bd6
commit 983476fbab
2 changed files with 14 additions and 8 deletions

View File

@ -1,3 +1,8 @@
Tue Oct 4 08:15:50 2011 Eric Hodel <drbrain@segment7.net>
* proc.c (proc_call): Update documentation to match argument handling
of proc/Proc.new/lambda/->()
Tue Oct 4 07:59:16 2011 Eric Hodel <drbrain@segment7.net> Tue Oct 4 07:59:16 2011 Eric Hodel <drbrain@segment7.net>
* proc.c (proc_call): Fix documentation of Proc#call vs Proc#===. * proc.c (proc_call): Fix documentation of Proc#call vs Proc#===.

17
proc.c
View File

@ -519,10 +519,10 @@ proc_lambda(void)
* to an array). Note that prc.() invokes prc.call() with the parameters * to an array). Note that prc.() invokes prc.call() with the parameters
* given. It's a syntax sugar to hide "call". * given. It's a syntax sugar to hide "call".
* *
* For procs created using <code>Kernel.proc</code> an error is generated * For procs created using <code>lambda</code> or <code>->()</code> an error
* if the wrong number of parameters are passed to a proc with multiple * is generated if the wrong number of parameters are passed to a Proc with
* parameters. For procs created using <code>Proc.new</code>, extra * multiple parameters. For procs created using <code>Proc.new</code> or
* parameters are silently discarded. * <code>Kernel.proc</code>, extra parameters are silently discarded.
* *
* Returns the value of the last expression evaluated in the block. See * Returns the value of the last expression evaluated in the block. See
* also <code>Proc#yield</code>. * also <code>Proc#yield</code>.
@ -530,14 +530,15 @@ proc_lambda(void)
* a_proc = Proc.new {|a, *b| b.collect {|i| i*a }} * a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
* a_proc.call(9, 1, 2, 3) #=> [9, 18, 27] * 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]
* a_proc = Proc.new {|a,b| a} * a_proc = lambda {|a,b| a}
* a_proc.call(1,2,3) * a_proc.call(1,2,3)
* *
* <em>produces:</em> * <em>produces:</em>
* *
* prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError) * prog.rb:4:in `block in <main>': wrong number of arguments (3 for 2) (ArgumentError)
* from prog.rb:4:in `call' * from prog.rb:5:in `call'
* from prog.rb:5 * from prog.rb:5:in `<main>'
*
*/ */
static VALUE static VALUE