Initialize array of arrays

You can do

julia> fill(Int[], 2, 3)
2×3 Array{Array{Int64,1},2}:
 []  []  []
 []  []  []

if it is fine to have the same empty vector everywhere or

julia> [Int[] for i=1:2, j=1:3]
2×3 Array{Array{Int64,1},2}:
 []  []  []
 []  []  []

if you need distinct empty vectors. The difference mostly matters if you intend to push data into the elements rather than replace them with new vectors.

9 Likes