Consider a situation where I first create a Vector with eltype
of Any
incrementally; after that, I want to narrow the element type of it. How can I do that?
julia> vec = Any[1, 2, 3.]
3-element Vector{Any}:
1
2
3.0
I can use something like convert(Vector{Real}, vec)
. But in this case, I'm specifying the type manually while I want Julia to decide the best suitable eltype
for it.
[i for i in v]
. – Caucasia