This behaviour is intended and as I understand it a relic from Matlab (where you can't have arrays of arrays). It is the basis for a convenient array construction from a range (eg, [1:5] gives [1,2,3,4,5] instead of an array with a Range object), so there are more to it than you might think.
There seems to be lots of people arguing against this behaviour, so I expect it to change at some point. See: #8599 <https://github.com/JuliaLang/julia/pull/8599> and linked issues for more discussion. Regards Ivar mandag 26. januar 2015 10.47.17 UTC+1 skrev Michael Partheil følgende: > > Dear all, > > just a short question about something I found quite a bit confusing: I > want to create an Array of Array of Int, so I wrote: > julia> [[1,2], [3,4]] > 4-element Array{Int64,1}: > 1 > 2 > 3 > 4 > > As you can see this turns into an Array of Ints instead, i.e. the inner > brackets are ignored. It works if I explicitly specify the type: > julia> Vector{Int}[[1,2], [3,4]] > 2-element Array{Array{Int64,1},1}: > [1,2] > [3,4] > > Is this behavior intended? Is there a better/recommended way to create an > Array of Arrays? I would be happy if someone could briefly clarify this! > > Thanks a lot > Michael > > PS: I'm using Julia 0.3.2 on OSX 10.9.5 >
