[](...) public

Invokes the block, setting the block’s parameters to the values in params 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).

For procs created using Kernel.proc, generates an error if the wrong number of parameters are passed to a proc with multiple parameters. For procs created using Proc.new, extra parameters are silently discarded.

Returns the value of the last expression evaluated in the block. See also Proc#yield.

   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 = Proc.new {|a,b| a}


   prog.rb:5: wrong number of arguments (3 for 2) (ArgumentError)
    from prog.rb:4:in `call'
    from prog.rb:5
Show source
Register or log in to add new notes.