# How to get methods of functor?

**URL:** <https://discourse.julialang.org/t/how-to-get-methods-of-functor/101050>\
**Category:** General Usage\
**Tags:** functors\
**Created:** [July 1, 2023, 1:03pm UTC](https://discourse.julialang.org/t/how-to-get-methods-of-functor/101050 "2023-07-01T13:03:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [July 1, 2023, 1:03pm UTC](https://discourse.julialang.org/t/how-to-get-methods-of-functor/101050/1 "2023-07-01T13:03:54Z")

</div>

How to get methods of functor?

```julia
julia> foo() = 2;
julia> foo(x) = x + 2;
julia> methods(foo)
# 2 methods for generic function "foo":
[1] foo() in Main at REPL[21]:1
[2] foo(x) in Main at REPL[22]:1
julia> struct Foo x end;
julia> (obj::Foo)() = obj.x;
julia> (obj::Foo)(x) = obj.x + x;
julia> methods(Foo)
# 1 method for type constructor:
[1] Foo(x) in Main at REPL[1]:1

```

---

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [July 1, 2023, 1:04pm UTC](https://discourse.julialang.org/t/how-to-get-methods-of-functor/101050/2 "2023-07-01T13:04:51Z")

</div>

```julia
julia> foo = Foo(2);
julia> methods(foo)
# 2 methods for callable object:
[1] (obj::Foo)() in Main at REPL[1]:1
[2] (obj::Foo)(x) in Main at REPL[2]:1

```
