I want to convert this Any[1,2,3,4] to string but it gives “Any[1,2,3,4]”, it should give “[1,2,3,4]”
a = Any[1,2,3,4]
println(a)
println(convert(Vector{Int}, a))
yields
Any[1, 2, 3, 4]
[1, 2, 3, 4]
1 Like
The larger question here is why this is a Vector{Any}
and not a Vector{Int}
from the start. Converting the whole array seem a little overkill just for printing. You could also easily do:
julia> a = Any[1, 2, 3, 4]
4-element Array{Any,1}:
1
2
3
4
julia> chop(string(a); head = 3, tail = 0)
"[1, 2, 3, 4]"
2 Likes