How can I fill an array with empty 2D arrays?

Yes, I am replacing the entire array, using it a bit like this:

julia> a=fill(Array{Float32,2}(undef,0,0),1,3);

julia> a[1]=rand(2,2); a[2]=rand(3,3);

julia> a[:]
3-element Array{Array{Float32,2},1}:
 [0.92491776 0.93883944; 0.9667731 0.9894779]
 [0.13091879 0.37846377 0.07404064; 0.71520746 0.9362733 0.41508183; 0.8309387 0.73587126 0.0631132]      
 Array{Float32}(undef,0,0)

I understand that I could just push the new one as it is generated, however I think pre-allocating makes the code more readable as you know where each array is going to go beforehand, instead of counting how many pushes there are.

1 Like