julia> extrema(map(m->length(m.sig), methods(+)))
(1,5)

I guess you could check that the min and max match and raise an error
otherwise. This doesn't take into account varargs.

On Thu, Oct 16, 2014 at 12:38 PM, Ethan Anderes <[email protected]>
wrote:

> I don’t know of such a function but if you just wanted information from
> the REPL methods will give you a list. Does that help?
>
>
> julia> foo(x,y,z) = 4
> foo (generic function with 1 method)
>
> julia> foo(x,y) = 4
> foo (generic function with 2 methods)
>
> julia> methods(foo)
> # 2 methods for generic function "foo":
> foo(x,y,z) at none:1
> foo(x,y) at none:1
>
> On Thursday, October 16, 2014 7:30:02 AM UTC-7, Evan Pu wrote:
>
> I'm assuming the function only has a single method, although a more
>> general answer would be nice too.
>> Imagine I have:
>> f(x,y,z) = x + y + z
>>
>> I would like to have something like
>> num_args(f)
>> which should give back 3
>>
>> is there something that could let me do this?
>> thanks a lot!!
>>
> ​
>

Reply via email to