# Alternative to mutable named tuple?

**URL:** <https://discourse.julialang.org/t/alternative-to-mutable-named-tuple/38375>\
**Category:** General Usage\
**Created:** [April 28, 2020, 2:39pm UTC](https://discourse.julialang.org/t/alternative-to-mutable-named-tuple/38375 "2020-04-28T14:39:02Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [April 28, 2020, 8:39pm UTC](https://discourse.julialang.org/t/alternative-to-mutable-named-tuple/38375/8 "2020-04-28T20:39:38Z")

</div>

I’m going to just follow up on my earlier post with an example:

```julia
using StructArrays
julia> x = [(a=1, b=2), (a=3, b=4)]
2-element Array{NamedTuple{(:a, :b),Tuple{Int64,Int64}},1}:
 (a = 1, b = 2)
 (a = 3, b = 4)

julia> sx = StructArray(x)
2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}:
 (a = 1, b = 2)
 (a = 3, b = 4)

julia> sx.b .= 1
2-element Array{Int64,1}:
 1
 1

julia> sx
2-element StructArray(::Array{Int64,1}, ::Array{Int64,1}) with eltype NamedTuple{(:a, :b),Tuple{Int64,Int64}}:
 (a = 1, b = 1)
 (a = 3, b = 1)

```

It doesn’t get easier than that. As far as memory usage, I think you probably shouldn’t worry about it unless these are huge vectors, in which case you probably want to do something different entirely.

---

_[View the full topic](https://discourse.julialang.org/t/alternative-to-mutable-named-tuple/38375)._
