On Thu, Feb 25, 2016 at 7:51 PM, Ilya Orson <[email protected]> wrote: > Hello everyone, > > I am working with a matrix of initially empty vectors and wanted to fill > each vector with specific elements using push!, but I get a weird result: > > > matrix = fill(Int64[],2,2) > > 2x2 Array{Array{Int64,1},2}: > Int64[] Int64[] > Int64[] Int64[] > > > > push!(matrix[1,1],3,2) > > 2-element Array{Int64,1}: > 3 > 2 > > > > But this results in: > > > matrix > > 2x2 Array{Array{Int64,1},2}: > [3,2] [3,2] > [3,2] [3,2] > > > > I wanted something like this: > > > matrix > > 2x2 Array{Array{Int64,1},2}: > [3,2] Int64[] > Int64[] Int64[] > > > > Is this behaviour to be expected? > > > I am using julia 0.4.2 and append! does the same thing. >
Yes. http://julia.readthedocs.org/en/latest/stdlib/arrays/?highlight=fill#Base.fill > > Any advice or workarounds would be apreciated! > >
