julia> Vector[[1,2], [3, 4]]
2-element Array{Array{T,1},1}:
 [1,2]
 [3,4]

julia> [[1,2] [3,4]]
2x2 Array{Int64,2}:
 1  3
 2  4

julia> [[1,2], [3,4]]
WARNING: [a,b] concatenation is deprecated; use [a;b] instead
 in depwarn at deprecated.jl:73
 in oldstyle_vcat_warning at ./abstractarray.jl:29
 in vect at abstractarray.jl:32
while loading no file, in expression starting on line 0
4-element Array{Int64,1}:
 1
 2
 3
 4

julia> [[1,2]; [3,4]]
4-element Array{Int64,1}:
 1
 2
 3
 4

On 5 January 2016 at 19:38, Erik Schnetter <schnet...@gmail.com> wrote:
> I believe you have to first create an empty array, and then assign to
> each individual element.
>
> If the outer array is small, then you can take a work-around via a tuple:
>
> collect(([1,2], [3,4]))
>
> -erik
>
>
> On Tue, Jan 5, 2016 at 2:28 PM, Alex <updates...@gmail.com> wrote:
>> Hello,
>>
>> How to construct without push! equivalent vector of vectors?
>>
>> a=[]
>> push!(a, [1,2])
>> push!(a, [2,3])
>>
>> it gives:
>> # 2-element Array{Any,1}:
>> # [1,2]
>> # [2,3]
>>
>> If  i type
>>
>> a=[[1,2],[2,3]]
>> it gives me a 4-element array.
>
>
>
> --
> Erik Schnetter <schnet...@gmail.com>
> http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to