# Push into array of arrays does not work when type is specified

**URL:** https://discourse.julialang.org/t/push-into-array-of-arrays-does-not-work-when-type-is-specified/52151
**Category:** General Usage
**Tags:** array, type
**Created:** [December 21, 2020, 1:40am UTC](https://discourse.julialang.org/t/push-into-array-of-arrays-does-not-work-when-type-is-specified/52151 "2020-12-21T01:40:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ZdM87](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdm87/32/15353_2.png) [@ZdM87](https://discourse.julialang.org/u/ZdM87)
#### Post date: [December 21, 2020, 1:40am UTC](https://discourse.julialang.org/t/push-into-array-of-arrays-does-not-work-when-type-is-specified/52151/1 "2020-12-21T01:40:36Z")

</div>

Why the following code works

```julia
using Combinatorics

all_sequences = []
for i in 2:4
    for j in permutations(1:4, i)
        push!(all_sequences, collect(j))
    end
end

```

and this one does not

```julia
using Combinatorics

all_sequences = Array{Array{Int64,1},1}[]
for i in 2:4
    for j in permutations(1:4, i)
        push!(all_sequences, collect(j))
    end
end

```

and gives the error message: `ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Array{Int64,1}`.

When I specify the array `all_sequences` type as `Array{Array{Int64,1},1}`, I got the error. However, the array `all_sequences` type is nothing but `Array{Array{Int64,1},1}`, no?

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [December 21, 2020, 2:20am UTC](https://discourse.julialang.org/t/push-into-array-of-arrays-does-not-work-when-type-is-specified/52151/2 "2020-12-21T02:20:02Z")

</div>

Your second code creates an array-of-arrays-of-arrays:

```julia
> Array{Array{Int64,1},1}[] |> typeof
Vector{Vector{Vector{Int64}}}

```

To create array-of-arrays do:

```julia
> Vector{Int64}[] |> typeof
Vector{Vector{Int64}}

```

or

```julia
> Vector{Vector{Int64}}() |> typeof
Vector{Vector{Int64}}

```
