struct MyStruct
v::String
end
function Base.show(io::IO, val::MyStruct)
if haskey(io, :compact)
write(io, "[$(io[:compact])]$(val.v)]")
else
write(io, val.v)
end
end
a = [MyStruct("a"), MyStruct("b"), MyStruct("c")]
prints
3-element Vector{MyStruct}:
a
b
c
in the REPL, and "$a" prints as "MyStruct[a, b, c]".
So where does :compact actually come into play in normal usage?
Sorry to revive but I also just stumbled over this. Given that the documentation states
:compact: Boolean specifying that values should be printed more compactly, e.g. that numbers should be printed with fewer digits. This is set when printing array elements.:compact output should not contain line breaks.
and given that Vector is an array, isn’t the current behavior for one-dimensional arrays inconsistent with what is stated in the docs?
Irrespective of what it should be, is there currently a way to get the compact show also for a vector of custom elements?