Overloading of show()


#1

Where is overloading of show() here?

julia> struct Polar{T<:Real} <: Number
           r::T
           Θ::T
       end

julia> Polar(r::Real,Θ::Real) = Polar(promote(r,Θ)...)
Polar

https://docs.julialang.org/en/stable/manual/types/#Custom-pretty-printing-1


#2

Look a few lines down on the page you have linked to:

julia> Base.show(io::IO, z::Polar) = print(io, z.r, " * exp(", z.Θ, "im)")

#3

More fine-grained control over display of Polar objects is possible. In particular, sometimes one wants both a verbose multi-line printing format, used for displaying a single object in the REPL and other interactive environments, and also a more compact single-line format used for print() or for displaying the object as part of another object (e.g. in an array). Although by default the show(io, z) function is called in both cases, you can define a different multi-line format for displaying an object by overloading a three-argument form of show that takes the text/plain MIME type as its second argument (see Multimedia I/O), for example:

More control over display of Polar objects is possible.
For displaying a single object with multi-line printing format and for displaying the object as part of another object (e.g. in an array) with compact single-line format, define a different multi-line format by overloading show() that takes type text/plain MIME as the second argument, e.g.