Is it possible to dispatch on the arity of a function?

Say I want to dispatch fn(gn::Function) base on the arity of gn. Is it possible?

1 Like

Check out this thread

TL;DR: isapplicable applicable is probably your best approach for this

2 Likes

Methods are not first-class citizens in Julia, so you can’t directly dispatch on the signature of a function. Using isapplicabile in the body of the function is an option, FunctionWrappers.jl is also often recommended in these cases, depending on what you exactly want to achieve

6 Likes

That is incorrect, according to the thread it is applicable instead of isapplicable:

1 Like

Yep, my bad