# Ho can I append a value into initialised array without first empty row?

**URL:** <https://discourse.julialang.org/t/ho-can-i-append-a-value-into-initialised-array-without-first-empty-row/27443>\
**Category:** General Usage\
**Tags:** array\
**Created:** [August 12, 2019, 8:09am UTC](https://discourse.julialang.org/t/ho-can-i-append-a-value-into-initialised-array-without-first-empty-row/27443 "2019-08-12T08:09:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manu\_Francis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manu_francis/32/10010_2.png) [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Post date:** [August 12, 2019, 8:09am UTC](https://discourse.julialang.org/t/ho-can-i-append-a-value-into-initialised-array-without-first-empty-row/27443/1 "2019-08-12T08:09:36Z")

</div>

Hi,

I am trying to append some values into an initialized array. But first elements of this array is not the first appended value. I did like follows:

```julia
#initialized an array
a = Array{Float64,1}
#append into a
a = [a;5;6]
print(a)

```

The output is as follows:

```julia
2-element Array{Any,1}:
  Array{Float64,1}
 5
 6

```

But I don’t need ` Array{Float64,1}` as my first element? I just need an array with two elements

```julia
2-element Array{Any,1}:
 5
 6

```

I can do it by using `a[2:end]` but is there any other method to solve this issue?

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [August 12, 2019, 8:30am UTC](https://discourse.julialang.org/t/ho-can-i-append-a-value-into-initialised-array-without-first-empty-row/27443/2 "2019-08-12T08:30:48Z")

</div>

`a = Array{Float64,1}` doesn’t do what you think it does, as it assigns the type `Array{Float64,1}` to `a`. What you’re probably looking for is `a = Array{Float64,1}()`, so you’re actually calling the constructor. A shorter way to achive this would also be `a = Float64[]`. Are you also sure that you want to use the non-inplace `vcat` (eg. `[a; b]`)? You might want to have a look at `push!` or `append!`.

---

<div class="post-metadata">

**Author:** ![Manu\_Francis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manu_francis/32/10010_2.png) [@Manu\_Francis](https://discourse.julialang.org/u/Manu_Francis)\
**Post date:** [August 12, 2019, 10:39am UTC](https://discourse.julialang.org/t/ho-can-i-append-a-value-into-initialised-array-without-first-empty-row/27443/3 "2019-08-12T10:39:35Z")

</div>

@simeonschaub: Thanks a lot for your reply. I am a beginner and still, I have some confusions with variable initializations because I just moved from MATLAB to julia.
