# Append struct element to an array

**URL:** <https://discourse.julialang.org/t/append-struct-element-to-an-array/19439>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 9, 2019, 4:42pm UTC](https://discourse.julialang.org/t/append-struct-element-to-an-array/19439 "2019-01-09T16:42:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![algebrato](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/algebrato/32/6778_2.png) [@algebrato](https://discourse.julialang.org/u/algebrato)\
**Post date:** [January 9, 2019, 4:42pm UTC](https://discourse.julialang.org/t/append-struct-element-to-an-array/19439/1 "2019-01-09T16:42:49Z")

</div>

Hello,  
I am a newbie programmer in Julia, and I can not explain a bizarre behavior of the **append** command.  
I have a structure define as

```julia
struct Point{T}
  x::T
  y::T
  z::T
end 

```

and an array of points:

```julia
points = [Point{Float64}(rand(),rand(),rand()) for i = 1:100]

```

if I create another point:

```julia
p = Point{Float64}(1.0, 1.0, 1.0)

```

Why I can not append it to the points array?

```julia
julia> append!(points,p)
ERROR: MethodError: no method matching length(::Point{Float64})
Closest candidates are:
  length(::Core.SimpleVector) at essentials.jl:582
  length(::Base.MethodList) at reflection.jl:732
  length(::Core.MethodTable) at reflection.jl:806
  ...
Stacktrace:
 [1] _append!(::Array{Point{Float64},1}, ::Base.HasLength, ::Point{Float64}) at ./array.jl:908
 [2] append!(::Array{Point{Float64},1}, ::Point{Float64}) at ./array.jl:902
 [3] top-level scope at none:0

```

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [January 9, 2019, 4:43pm UTC](https://discourse.julialang.org/t/append-struct-element-to-an-array/19439/2 "2019-01-09T16:43:47Z")

</div>

You want `push!` to add just a single element to the end of an array. `append!` tries to add an array of many elements.
