# Vector of vectors

**URL:** https://discourse.julialang.org/t/vector-of-vectors/13748
**Category:** General Usage
**Created:** [August 20, 2018, 5:34am UTC](https://discourse.julialang.org/t/vector-of-vectors/13748 "2018-08-20T05:34:50Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [August 20, 2018, 5:51am UTC](https://discourse.julialang.org/t/vector-of-vectors/13748/2 "2018-08-20T05:51:50Z")

</div>

Don’t post the same question on multiple forums without linking them to each other, [arrays - Resize Vectors Julia - Stack Overflow](https://stackoverflow.com/questions/51924323/resize-vectors-julia).

It is also helpful to make the example as [minimal as possible](https://stackoverflow.com/help/mcve). This has the benefit that you often realize yourself what is wrong.

Here is a smaller example that shows the same behaviour:

```julia
julia> A = [Vector{Any}(undef, 1)]
1-element Array{Array{Any,1},1}:
 [#undef]

julia> A[1][1]
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[...]

```

which is what happens when you call `resize!(A[tt][rr], b)` in your code: The entry `A[tt][rr]` is not initialized to anything, so you can not extract it and resize it.

Here is one, minimal, modification,that I think does what you want:

```julia
A = [Vector{Any}() for i in 1:6]
a, b, c, d = 3, 4, 5, 6
for tt = 1:6
    a+=1
    resize!(A[tt], a)
    for rr = 1:a
        b+=1
        A[tt][rr] = Vector{Any}(undef, b) # instead of resize!(A[tt][rr], b)
        for tt2 = 1:b
            A[tt][rr][tt2] = Vector{Any}(undef, b) # instead of resize!(A[tt][rr][tt2], b)
        end
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/vector-of-vectors/13748)._
