From: Robert Dober Date: 2007-05-30T15:22:07+09:00 Subject: Re: True arity On 5/29/07, Daniel DeLorme wrote: > Robert Dober wrote: > > On 5/29/07, Daniel DeLorme wrote: > >> Is there a way to get the *maximum* number of arguments that a method > >> can receive? Method#arity only gives the lower bound... > > > > I am afraid I fail to understand, what would you define as the maximum? > > > > def a(a)... I would say the maximum is 1 which is the arity > > def b(*b) arity is -1 but what would the maximum of parameters be? > > def c(c,*d) arity = -2 but some question as above. > > > > The question is, what would you like to achieve? > > 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) I know I missed something :(, indeed a good question, thx for explaining to a dummy ;). > 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) > > Daniel > > Cheers Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw