[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

wrong documentation

Daniel Whitter

1/13/2006 10:47:00 PM

Hello,

to ``proc.arity´´ it is documented:

>Returns the number of arguments required by the block. If the block
>takes no arguments, returns -1. If it takes one argument, returns -2.
>Otherwise, returns a positive argument count unless the last argument
>is prefixed with *, in which case the argument count is negated. The
>number of required arguments is anInteger for positive values, and (
>anInteger +1).abs otherwise.
>
>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

Fact is if you have only arguments without '*' the count of the
arguments is returned.
If you use a '*' for the last argument the return value of 'arity' is
negated.

Means the examples give:
0
1
2
3
-1
-2


greetings,
Daniel