# \`show\` method for \`Function\` subtype

**URL:** <https://discourse.julialang.org/t/show-method-for-function-subtype/77297>\
**Category:** General Usage\
**Created:** [March 2, 2022, 12:17pm UTC](https://discourse.julialang.org/t/show-method-for-function-subtype/77297 "2022-03-02T12:17:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [March 2, 2022, 12:17pm UTC](https://discourse.julialang.org/t/show-method-for-function-subtype/77297/1 "2022-03-02T12:17:18Z")

</div>

```julia
julia> struct MyFunction <: Function
              x
          end

julia> (f::MyFunction)(arg) = f.x*arg

julia> Base.show(io::IO, f::MyFunction) = println(io, "MyFunction with x=$(f.x)")

julia> f = MyFunction(3)
(::MyFunction) (generic function with 1 method)

julia> f
(::MyFunction) (generic function with 1 method)

julia> show(f)
f = MyFunction with x=3

```

The second and third to last lines invoke the `show` method for `Function`s, instead of my more specific `MyFunction` method. Is this a bug or a feature, and what can I do to overrule it?

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [March 2, 2022, 12:32pm UTC](https://discourse.julialang.org/t/show-method-for-function-subtype/77297/2 "2022-03-02T12:32:08Z")

</div>

I tried

```julia
julia> struct MyFunction <: Function
           x
       end

julia> (f::MyFunction)(arg) = f.x*arg

julia> Base.show(io::IO, ::MIME"text/plain", f::MyFunction) = println(io, "MyFunction with x=$(f.x)")

julia> f = MyFunction(3)
MyFunction with x=3

julia> f
MyFunction with x=3

julia> show(f)
MyFunction(3)

```
