I am declaring a custom type as Vector2Dim and i want to output to be printed with just the coordinates instead of Vector2Dim(x,y).
However the same code if i execute in julia console it prints the desired output as [x,y] and if i write the code in a file
and execute, it prints the output as Vector2Dim(x,y).
Kindly let me know what changes do i need to make it to get the correct output. Below is the code and its output.
Julia Version 0.5.1
IDE: atom(juno)
Code::
import Base.show
type Vector2Dim
x::Float64
y::Float64
end
a = Vector2Dim(3,4)
println(a)
show(io::IO, v::Vector2Dim) = print(io, "[$(v.x),$(v.y)]")
println(a)
Output::
Vector2Dim(3.0,4.0)
Vector2Dim(3.0,4.0)
The required output is [3.0, 4.0]