Say I have
struct MyStruct{T,U}
a::T
b::U
end
I'd like to define a custom show
which eliminates a lot of noise from the full type.
E.g. if I create the following:
z = MyStruct((a=1,b=2),rand(5))
then typeof
shows much more than I want:
julia> typeof(z)
MyStruct{NamedTuple{(:a, :b), Tuple{Int64, Int64}}, Vector{Float64}}
How can I programmatically get just MyStruct
from z
into a string?
typeof
result is very long because that's the concrete type of the instancez
.MyStruct
is an abstract type, specifically an iterated union (UnionAll
) of types with varying parametersT,U
. That may be fine for printing purposes, but just be aware that whenz
andz2
both printMyStruct
, it's very possible thattypeof(z) != typeof(z2)
. – Atonic