How to create array of arrays

How to create a array of arrays. I am trying this.

julia> a =[2,3]
2-element Array{Int64,1}:
 2
 3

julia> b=[]
0-element Array{Any,1}

julia> push!(b,a)
1-element Array{Any,1}:
 [2, 3]

julia> empty!(a)
0-element Array{Int64,1}

julia> b
1-element Array{Any,1}:
 Int64[]

Here the array b is empty. I want the array to be as it before deleting array a

Could you explain what exactly you are expecting? b isn’t empty in your example above:

julia> b[1]
Int64[]

there’s an empty array of integers in b (which you put there and then emptied).

2 Likes
push!(b,deepcopy(a))

or

push!(b,copy(a))

would be enough in above example case.

1 Like

Recent related thread:

1 Like

Thanks @oheil.