Hi Mauro, thanks for the response!
I get the logic behind an uninitialized array, but shouldn't such an array 
not return an iterable with 1 element of garbage? Why would it be 
initialized to having 1 random element and not 0?

I would expect an empty constructor to do something reasonable. Perhaps it 
would be logical for these two statements to be equivalent (see bold lines 
below). I don't see the value of having a null constructor that generates 
an array that's iterable with exactly 1 element of garbage contents. Seems 
like a recipe for bugs. My bugs specifically, which is exactly what brought 
me to this topic. :)

*julia> x = Array{Int64}()*
0-dimensional Array{Int64,0}:
2198389808

julia> x[1]
2198389808

julia> x[2]
ERROR: BoundsError: attempt to access 0-dimensional Array{Int64,0}:
2198389808
  at index [2]
 in getindex at array.jl:282

*julia> x=Array{Int64}(0)*
0-element Array{Int64,1}

julia> x[1]
ERROR: BoundsError: attempt to access 0-element Array{Int64,1}
  at index [1]
 in getindex at array.jl:282







Reply via email to