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

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-dispatch-on-the-arity-of-a-function/29266>\
**Category:** New to Julia\
**Created:** [September 28, 2019, 10:29am UTC](https://discourse.julialang.org/t/is-it-possible-to-dispatch-on-the-arity-of-a-function/29266 "2019-09-28T10:29:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pablosanjose](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pablosanjose/32/7006_2.png) [@pablosanjose](https://discourse.julialang.org/u/pablosanjose)\
**Post date:** [September 28, 2019, 11:12am UTC](https://discourse.julialang.org/t/is-it-possible-to-dispatch-on-the-arity-of-a-function/29266/2 "2019-09-28T11:12:48Z")

</div>

Check out this thread

> [@Finding the number of arguments of an anonymous function](https://discourse.julialang.org/t/finding-the-number-of-arguments-of-an-anonymous-function/24394):
>
> I have an API wherein a kwarg is a function. function apifunc(; f::Function = identity) ... end I would like to do something different depending on the number of arguments of f, so that apifunc(f = x -\> 2) calls \_apifunc1(f) but apifunc(f = (x,y) -\> 2) calls \_apifunc2(f). Is there a way to achieve that, preferably in a non-dynamical way? In other words, is there any way to do introspection on the allowed signatures of a function’s methods?

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

---

_[View the full topic](https://discourse.julialang.org/t/is-it-possible-to-dispatch-on-the-arity-of-a-function/29266)._
