# Finding all applicable Methods for Signature

**URL:** <https://discourse.julialang.org/t/finding-all-applicable-methods-for-signature/74008>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 3, 2022, 10:58pm UTC](https://discourse.julialang.org/t/finding-all-applicable-methods-for-signature/74008 "2022-01-03T22:58:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arik](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@arik](https://discourse.julialang.org/u/arik)\
**Post date:** [January 3, 2022, 10:58pm UTC](https://discourse.julialang.org/t/finding-all-applicable-methods-for-signature/74008/1 "2022-01-03T22:58:21Z")

</div>

Hi there. Im looking to programmatically create a list of all Methods of a given function `f` whose signature is compatible with a given argument list `args`, that is, a list of all methods that could be triggered by `invoke(f, argtypes, args...)` with the right `argtypes`.

For example, given the definition

```julia
f(i)=1
f(i::Number)=2
f(i::Int) = 3
f(i::String)=4

```

and an argument that is `Int`, I want a list containing the Methods for `Any`,`Number` and `Int`, but NOT the Method for `String`. So essentially I want this:

```julia
julia> applicableMethods(f,Tuple{Int})
# 3 methods for generic function "f":
[1] f(i::Int64) in Main at REPL[9]:1
[2] f(i::Number) in Main at REPL[8]:1
[3] f(i) in Main at REPL[7]:1

```

The documentation for the `methods` function claims to do just that, but calling `methods(f,Tuple{Int})` returns a list with just one Method, the most specific one. (Is that a bug or intended?)

If there was a way to check a method against the given type signature, like `applicable(method, args...)` (which does not work on methods), I could `filter` the whole Method list, but I have not found an easy way of doing so, as this typechecking can be arbitrarily complicated with typeparameters or “slurping arguments”.

Any help appreciated!

---

<div class="post-metadata">

**Author:** ![Mark\_Nahabedian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mark_nahabedian/32/16562_2.png) [@Mark\_Nahabedian](https://discourse.julialang.org/u/Mark_Nahabedian)\
**Post date:** [December 13, 2024, 8:53pm UTC](https://discourse.julialang.org/t/finding-all-applicable-methods-for-signature/74008/2 "2024-12-13T20:53:53Z")

</div>

You’ve probably already figured this out, but for the sake of answering the thread, try `Base.which`.
