I would like to write a summary of a struct as a string.
So I did the following:
julia> struct Cell{R<:Int}
row::R
col::R
end
julia> import Base.print
julia> print(io::IO, c::Cell) = print(">>($(c.row),$(c.col))")
print (generic function with 32 methods)
julia> c=Cell(2,3)
Cell{Int64}(2, 3)
julia> "it is $c currently"
>>(2,3)"it is currently"
I think it is clear that this is not useful output.
My inclination would have been to write a string() method but if I understand the docs correctly print() is the preferred method to overload:
“Both concatenation and string interpolation call string to convert objects into string form. However, string actually just returns the output of print, so new types should add methods to print or [show](I/O and Network · The Julia Language{IO, Any}) instead of string.”
Could somebody point me in teh right direction, please?
Many thanks.