Weird Base.show behavior with custom Struct

Yeah, this is a bit confusing, the explanation for it is buried in here: Types · The Julia Language

Basically, when you display a top level form in the REPL, what get’s called is not show(stdout, x) but instead show(stdout, MIME"text/plain"(), x). So the easiest fix for you would be to write something like

Base.show(io::IO, space::myNewGraph) = println(io, "My new type with $(space.ne) edge")
Base.show(io::IO, ::MIME"text/plain", space::myNewGraph) = show(io, space)
1 Like