自分でtypeしたComposite Typeのprint/printlnについて、以下のような実装をしている。参考にした情報はだいぶ古い。一応Julia v0.5.0(2016-09-19-18:14 UTC)とv0.6.0(2017-06-19 13:05 UTC)で動いた。何を実装するのが一番いい感じのやり方なのか知りたい。
- There is no documentation for custom printing of user-defined types #9458 https://github.com/JuliaLang/julia/issues/9458
# 宣言
type MyInterval
s::Int64
e::Int64
end
function Base.show(io::IO, itv::MyInterval)
print(io, "[$(itv.s),$(itv.e)]")
end
# 実行
julia> itv = MyInterval(1, 10)
[1, 10]
julia> println(itv)
[1, 10]