# Arrays of User Types

**URL:** <https://discourse.julialang.org/t/arrays-of-user-types/15348>\
**Category:** General Usage\
**Created:** [September 22, 2018, 6:23pm UTC](https://discourse.julialang.org/t/arrays-of-user-types/15348 "2018-09-22T18:23:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fanny](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Fanny](https://discourse.julialang.org/u/Fanny)\
**Post date:** [September 22, 2018, 6:23pm UTC](https://discourse.julialang.org/t/arrays-of-user-types/15348/1 "2018-09-22T18:23:53Z")

</div>

Using Julia 1.0, I am creating a mutable struct XX with two Float64 fields, x and y. I then use AA = fill(XX(100.0,200.0),10) to create an Array of type XX. However, when i type AA[1].x = 300.0, it seems to change the x value for the entire array. Is there a better way to do this?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [September 22, 2018, 6:25pm UTC](https://discourse.julialang.org/t/arrays-of-user-types/15348/2 "2018-09-22T18:25:15Z")

</div>

That puts the same `XX` object in every slot of the array. If you want a different `XX` object in each slot of the array, you can do something like this:

```julia
AA = [XX(0.0, 0.0) for _ = 1:10]

```

---

<div class="post-metadata">

**Author:** ![Fanny](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@Fanny](https://discourse.julialang.org/u/Fanny)\
**Post date:** [September 22, 2018, 6:39pm UTC](https://discourse.julialang.org/t/arrays-of-user-types/15348/3 "2018-09-22T18:39:57Z")

</div>

Thank you for your help! I do appreciate it very much. Your suggestion works beautifully.
