Actually just [Int[] for i = 1:10] should be sufficient.
On Fri, Mar 14, 2014 at 7:31 PM, Tim Holy <[email protected]> wrote: > Construct it with > > array = Array{Int}[Int[] for i = 1:10] > > --Tim > > On Friday, March 14, 2014 04:13:55 PM Philipp Moritz wrote: >> Dear all, >> >> currently, executing the code >> >> array = fill(Array(Int, 0), 10) >> push!(array[1], 1) >> >> inserts the 1 to array[1], ..., array[10]. The reason is of course that >> fill doesn't deep copy the object it is being given. Is this desired >> behaviour? If it is, is there a better way to write above code other than >> >> array = Array(Array{Int}, 10) >> for i = 1:10 >> result[i] = Array(Int, 0) >> end >> push!(array[1], 1) >> >> Best, >> Philipp.
