julia> struct my
age :: Int
weight :: Float64
end
julia> function Base.show(io::IO, h::my)
print(io,"my struct")
end
Here I defined a struct and a new method for the function ‘show’. Then when I instantiate a variable
julia> a = my(34,45.0)
my struct
the function ‘show’ is invoked automatically. I did not call it. What is the mechanism behind?