```The Higgs bozo wrote:
> unknown wrote:
>> Hi all,
>>
>> I'd like to distinguish the two following blocks by means of their
>> arity, but in Ruby 1.8 I don't see how to do this as Proc#arity
>> returns the same value.
>>
>> lambda {}.arity => -1
>> lambda {|*a|}.arity => -1
>
> I suppose the answer is that they have the same arity.  These are all
> legal
>
> lambda {}.call
> lambda {}.call :hello
> lambda {}.call :hello, :world
>
> lambda { |*a| }.call
> lambda { |*a| }.call :hello
> lambda { |*a| }.call :hello, :world
>
> From the caller's point of view, I see nothing which would distinguish
> one from the other.

According the ri documentation

renard\$ ri Proc#arity
------------------------------------------------------------- Proc#arity
prc.arity -> fixnum
------------------------------------------------------------------------
Returns the number of arguments that would not be ignored. If the
block is declared to take no arguments, returns 0. If the block is
known to take exactly n arguments, returns n. If the block has
optional arguments, return -n-1, where n is the number of
mandatory arguments. A proc with no argument declarations is the
same a block declaring || as its arguments.

Proc.new {}.arity          #=>  0
Proc.new {||}.arity        #=>  0
Proc.new {|a|}.arity       #=>  1
Proc.new {|a,b|}.arity     #=>  2
Proc.new {|a,b,c|}.arity   #=>  3
Proc.new {|*a|}.arity      #=> -1
Proc.new {|a,*b|}.arity    #=> -2

Note that Proc.new().arity should return a 0, however it returns  -1
!!!!

renard\$ irb --simple-prompt
>> Proc.new {}.arity
=> -1
>>

I would consider that to be a bug

The ri documentation states that Proc.new {}.arity ande Proc.new{||} are
equivalent. Proc.new{||}.arity
does return a 0.

>> Proc.new {||}.arity
=> 0

lambda {}.arity has the same bug. Thus the OP should use lambda {||}
--
Posted via http://www.ruby-forum.com/.

```