I was reading about Array initialization, and it talks about using the undef
keyword for an uninitialized array. However, if you leave out the undef
keyword and pass an iterable, you can create an array, for example:
numbers = Array{Int}([1,2,3,4,5])
5-element Array{Int32,1}:
1
2
3
4
5
This is a conversion. Such as from a float array:
julia> numbers = Array{Int}(Float64[1,2,3,4,5])
5-element Array{Int64,1}:
1
2
3
4
5
2 Likes
Yea this is actually just a conversion. You are constructing the array with [1,2,3,4,5]
Is it documented anywhere that it’s a conversion? Your code obviously demonstrates it, but it seems I stumbled on conversion and thought it was initialization.