# Modifying the element in the vector of vectors

**URL:** <https://discourse.julialang.org/t/modifying-the-element-in-the-vector-of-vectors/104994>\
**Category:** General Usage\
**Created:** [October 16, 2023, 3:01am UTC](https://discourse.julialang.org/t/modifying-the-element-in-the-vector-of-vectors/104994 "2023-10-16T03:01:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKY](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@MKY](https://discourse.julialang.org/u/MKY)\
**Post date:** [October 16, 2023, 3:01am UTC](https://discourse.julialang.org/t/modifying-the-element-in-the-vector-of-vectors/104994/1 "2023-10-16T03:01:56Z")

</div>

![Screenshot 2023-10-16 105731](https://global.discourse-cdn.com/julialang/original/3X/8/a/8a0514bf9906cb3c82807d7e0544a8d413654450.png)  
What should I do if I just want to modify the fifth element in the third vector?

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [October 16, 2023, 7:12am UTC](https://discourse.julialang.org/t/modifying-the-element-in-the-vector-of-vectors/104994/2 "2023-10-16T07:12:03Z")

</div>

The vector of vectors, has several copies of the same vector (backed by same memory). The proper way to initialize a vector with different vectors is:

```julia
waccf = [zeros(5) for _ in 1:7]

```

This way, every vector is in a different memory location and the assignment works as expected.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [October 16, 2023, 7:36am UTC](https://discourse.julialang.org/t/modifying-the-element-in-the-vector-of-vectors/104994/3 "2023-10-16T07:36:12Z")

</div>

> [@Dan](#):
>
> several copies of the same vector (backed by same memory)

To nitpick on terminology, it’s the same vector referenced by all elements of the vector-vector; `copy` implies different memory.
