From: Charles Oliver Nutter Date: 2007-05-30T17:57:10+09:00 Subject: Re: True arity Daniel DeLorme wrote: > In the last 2 cases you give the maximum would be Infinity. But in a > case like this: > def foo(a, b=nil, c=nil) > the maximum would be 3 but arity only gives me -2 which means "this > method has 1 required argument". If I invoke the method like: > foo(*args) > I want to know for what size of args is this valid? It would be nice if > arity returned a Range object (1..3) It could be done, but the current Ruby implementations don't provide this information. Of course, all of them could...we know how many required arguments there are, we know how many optional arguments there are, and we know if there's a "rest" arg or not. Maximum = ...base arity if no optional args or rest arg ...base arity plus optional arg count if no rest arg ...infinity if rest arg in any case Minimum = ...well you know it, because we have this today. I guess the question would be whether this is useful enough information to warrant a semantic change in "arity" representation. - Charlie