# Push! not working as expected

**URL:** https://discourse.julialang.org/t/push-not-working-as-expected/81563
**Category:** General Usage
**Tags:** question
**Created:** [May 24, 2022, 9:18am UTC](https://discourse.julialang.org/t/push-not-working-as-expected/81563 "2022-05-24T09:18:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [May 24, 2022, 9:18am UTC](https://discourse.julialang.org/t/push-not-working-as-expected/81563/1 "2022-05-24T09:18:14Z")

</div>

What am I doing wrong here:

```julia
using KiteUtils
s=demo_state(7)
vec=Vector{SysState{7}}[]
typeof(s)

```

Output

```julia
SysState{7}

```

Now I try to push s into the vector `vec`

```julia
julia> push!(vec,s)
ERROR: MethodError: Cannot `convert` an object of type SysState{7} to an object of type Vector{SysState{7}}
Closest candidates are:
  convert(::Type{T}, ::LinearAlgebra.Factorization) where T<:AbstractArray at ~/packages/julias/julia-1.7/share/julia/stdlib/v1.7/LinearAlgebra/src/factorization.jl:58
  convert(::Type{Array{T, N}}, ::FillArrays.Zeros{V, N}) where {T, V, N} at ~/.julia/packages/FillArrays/5Arin/src/FillArrays.jl:440
  convert(::Type{Array{T, N}}, ::FillArrays.Ones{V, N}) where {T, V, N} at ~/.julia/packages/FillArrays/5Arin/src/FillArrays.jl:440
  ...
Stacktrace:
 [1] push!(a::Vector{Vector{SysState{7}}}, item::SysState{7})
   @ Base ./array.jl:994
 [2] top-level scope
   @ REPL[7]:1

```

Any idea why this doesn’t work?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [May 24, 2022, 9:23am UTC](https://discourse.julialang.org/t/push-not-working-as-expected/81563/2 "2022-05-24T09:23:24Z")

</div>

`Vector{SysState{7}}[]` constructs a vector of vectors:

```julia
julia> typeof(vec)
Vector{Vector{SysState{7}}}

```

You’ll need to write that as `SysState{7}[]` or `Vector{SysState{7}}()` instead.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [May 24, 2022, 9:32am UTC](https://discourse.julialang.org/t/push-not-working-as-expected/81563/3 "2022-05-24T09:32:07Z")

</div>

```julia
vec=SysState{7}[]
push!(vec, s)

```

Works…

Sorry for the noise…
