Arguments to procs

Hi, this seems inconsistent to me:

irb(main):005:0> Proc.new {|a|}.arity
=> -1
irb(main):006:0> Proc.new {|a,|}.arity
=> 1
irb(main):007:0> Proc.new {|a,b|}.arity
=> 2
irb(main):008:0> Proc.new {|a,b,|}.arity
=> 2

Is there any reason why the single argument case has special
processing?
In the first case, if the proc is called with more than one argument
’a’ will get an array.
In the third case only two args are allowed - no different from case
4.
But should it not be that case 3 can have one or more args (arity =
-2)?

Yes, you can always do what you want with * args, but it seems
inconsistent.

/haldane

Hi,

Is there any reason why the single argument case has special
processing?

Block parameters behave like LHS of assignment.

Proc.new {|a|}.call(1)

works like

a = 1

and

Proc.new {|a|}.call(1,2)

is like

a = 1,2

						matz.
···

In message “arguments to procs” on 03/03/27, haldane jbshaldane@hotmail.com writes: