# Base.similar (and Zygote.Buffer) returning undefined instead of array of arrays

**URL:** <https://discourse.julialang.org/t/base-similar-and-zygote-buffer-returning-undefined-instead-of-array-of-arrays/48078>\
**Category:** General Usage\
**Created:** [October 10, 2020, 12:01am UTC](https://discourse.julialang.org/t/base-similar-and-zygote-buffer-returning-undefined-instead-of-array-of-arrays/48078 "2020-10-10T00:01:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaglino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vaglino/32/16669_2.png) [@vaglino](https://discourse.julialang.org/u/vaglino)\
**Post date:** [October 10, 2020, 12:01am UTC](https://discourse.julialang.org/t/base-similar-and-zygote-buffer-returning-undefined-instead-of-array-of-arrays/48078/1 "2020-10-10T00:01:28Z")

</div>

I am trying to initialize an array of arrays using similar and Zygote.buffer.  
If I initialize an array the functions work as expected, i.e.

```julia
a = [0., 0.]

similar(a)
2-element Array{Float64,1}:
 7.229478454414514e221
 2.00297683e-315

```

when I enter an array of arrays as input, I would expect it to output an array of arrays, instead the function returns an array of undefined:

```julia
a = [[0.,0.],[0.,0.]]

similar(a)
2-element Array{Array{Float64,1},1}:
 #undef
 #undef

```

The Zygote.Buffer function acts in the same fashion.  
What am I missing here?

Thanks!

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 10, 2020, 3:04am UTC](https://discourse.julialang.org/t/base-similar-and-zygote-buffer-returning-undefined-instead-of-array-of-arrays/48078/2 "2020-10-10T03:04:12Z")

</div>

> [@vaglino](#):
>
> `2-element Array{Array{Float64,1},1}:`

`similar` gives you **un** initialized mutable array of the same type and size.

In this case, it _is_ an array of array. Notice, your first example is also “uninitialized” (the fact that two numbers are all over the places).
