Brian Candler wrote:
> On Wed, Nov 12, 2008 at 11:13:18PM +0900, Thomas Enebo wrote:
>   
>>>   class Foo
>>>     define_method(:foo) { |a,(b,c)| p a,b,c }
>>>   end
>>>
>>>   Foo.new.foo(1,[2,3])
>>>   puts "Arity: #{Foo.new.method(:foo).arity}"
>>>
>>> So foo has an arity of 2. But if you pass anything other than a two-element
>>> array for the second argument, you get an ArgumentError: wrong number of
>>> arguments.
>>>
>>> This suggests to me that the arguments structure needs to be nestable; the
>>> second argument is itself an argument list.
>>>
>>>   
>>>       
>> I question the validity of Arity for this case since the arity is really 3.
>>     
>
> I don't think so:
>
> class Foo
>   define_method(:foo) { |a,(b,c)| p a,b,c }
> end
>
> Foo.new.foo(1,2,3) rescue(puts "pants")      # => pants
> Foo.new.foo(1,[2]) rescue(puts "pants")      # => pants
> Foo.new.foo(1,[2,3,4]) rescue(puts "pants")  # => pants
>
> You must pass exactly two arguments to #foo, which by my understanding of
> arity means the arity is 2. But the second argument must be an Array with
> exactly two elements.
>   
Yes I guess I can accept arity 2...though you still need three arguments 
total to be supplied for the method to invoke (1 + 2 args in array).  I 
guess arity really is not so helpful once you enter this type of signature.

-Tom