Bug #574: Proc.new{}.arity is equal to -1 instead of 0
http://redmine.ruby-lang.org/issues/show/574

Author: Andrea Forni
Status: Open, Priority: Normal

In the ruby documentation for the versions 1.8.6, 1.8.7 and 1.9 is written about the method Proc#arity:
   Proc.new {}.arity          #=>  0
   Proc.new {||}.arity        #=>  0
   Proc.new {|a|}.arity       #=>  1
   ...
But in my scripts Proc.new{}.arity is equal to -1 and Proc.new{||}.arity is equal to zero.

The script attached to this issue shows the problem. I have tested it in my Linux box (Ubuntu hardy 8.04LTS architecture: i686 ) using both:
1) ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
2) ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]

Here the output:
$ ruby --version
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
$ ruby proc_arity.rb 
-1
0
1
2
3
$ ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
$ ruby proc_arity.rb 
-1
0
1
2
3

Where is the problem? It's a ruby's bug or a documentation one?


----------------------------------------
http://redmine.ruby-lang.org