[Beginner] How do I see the methods on a type I'm extending?

You have a typo in Thing’s name field, as it has name::AbstractString) instead of name::AbstractString. Also, your second sayer definition will overwrite the first, because you’re missing the type to make it distinct.

It should be like this:

function sayer(t::Thing)
  println(t.name)
end

function sayer(t_h::ThingHolder)
  print(t_h.holding.name)
end

You can also remove print and println here, because the result will be displayed nevertheless.

There is no such list of all methods that accept a specific type, for a very simple reason: there are too many of them (i.e. many methods are type generic).

A few things can help you:

  1. check methods to construct a specific type
julia> methods(ThingHolder)
# 2 methods for type constructor:
[1] ThingHolder(holding::Thing) in Main at REPL[14]:2
[2] ThingHolder(holding) in Main at REPL[14]:2
  1. check methods of a function which uses multiple dispatch
julia> methods(sayer)
# 2 methods for generic function "sayer":
[1] sayer(t_h::ThingHolder) in Main at REPL[23]:1
[2] sayer(t::Thing) in Main at REPL[22]:1
  1. check which method gets called for specific argument types
julia> which(sayer, [ThingHolder])
sayer(t_h::ThingHolder) in Main at REPL[23]:1

julia> which(sayer, [Thing])
sayer(t::Thing) in Main at REPL[22]:1 
2 Likes