# Trying to reference a struct field into an array

**URL:** <https://discourse.julialang.org/t/trying-to-reference-a-struct-field-into-an-array/86366>\
**Category:** New to Julia\
**Tags:** arrays, struct\
**Created:** [August 25, 2022, 10:03pm UTC](https://discourse.julialang.org/t/trying-to-reference-a-struct-field-into-an-array/86366 "2022-08-25T22:03:17Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Jollywatt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jollywatt/32/202198_2.png) [@Jollywatt](https://discourse.julialang.org/u/Jollywatt)\
**Post date:** [August 25, 2022, 10:40pm UTC](https://discourse.julialang.org/t/trying-to-reference-a-struct-field-into-an-array/86366/3 "2022-08-25T22:40:06Z")

</div>

@jling is right — doing exactly what you ask for is impossible so long as the struct fields are immutable. But what you ask for is the default behavior for mutable fields (such as arrays or a number in a `Ref`), in which case the struct itself need not be mutable.

I just wanted to add, maybe you will find [`StructArrays.jl`](https://juliaarrays.github.io/StructArrays.jl/stable/) useful. It lets you deal with arrays-of-structs, while internally being a struct-of-arrays. Used in conjunction with [`Accessors.jl`](https://github.com/JuliaObjects/Accessors.jl), this can be pretty handy. See [this answer](https://discourse.julialang.org/t/does-this-style-of-property-broadcasting-already-exist/85288/4).

---

_[View the full topic](https://discourse.julialang.org/t/trying-to-reference-a-struct-field-into-an-array/86366)._
