Issue #5694 has been updated by Thomas Sawyer.


I never quite understood why ranges were never used. Something like:

  lambda{}.arity => 0
  lambda{|a| }.arity => 1
  lambda{|a,b| }.arity => 2

  lambda{|a=1| }.arity => 0..1
  lambda{|a,b=2| }.arity => 1..2

  lambda{|*a| }.arity => -1
  lambda{|a,*b| }.arity => 1..-2

  lambda{|a,b=2,*c| }.arity => 1..-3


----------------------------------------
Bug #5694: Proc#arity doesn't take optional arguments into account. 
http://redmine.ruby-lang.org/issues/5694

Author: Marc-Andre Lafortune
Status: Assigned
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: 
Target version: 


Currently:

    ->(foo = 42){}.arity # => 0, should be -1

This is contrary to the documentation and to what we should expect from the equivalent method definition.

Fixed in trunk, requesting backport for the 1.9 line.



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