How to determine the type of display on the Julia REPL page

I do not understand how I should determine the appearance of a type on Julia REPL. There are a number of similar sound functions, including: display, display, print, record, etc.

+4
source share
1 answer

You need to overload Base.show () for the type.

julia> import Base: show

julia> type Foo
           x
           y
           z
       end

julia> Base.show(io::IO, f::Foo) = println(io, "Foo: x=$(f.x), y=$(f.y), z=$(f.z)")
show (generic function with 98 methods)

julia> Foo("Hello ", "World", "!")
Foo: x=Hello, y=World, z=!
+8
source

Source: https://habr.com/ru/post/1614328/


All Articles