# Naming elements in a Matrix

**URL:** https://discourse.julialang.org/t/naming-elements-in-a-matrix/127553
**Category:** New to Julia
**Created:** [March 31, 2025, 2:29pm UTC](https://discourse.julialang.org/t/naming-elements-in-a-matrix/127553 "2025-03-31T14:29:49Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)
#### Post date: [April 1, 2025, 7:09am UTC](https://discourse.julialang.org/t/naming-elements-in-a-matrix/127553/9 "2025-04-01T07:09:28Z")

</div>

> [@WalterMadelim](#):
>
> To be honest, I don’t find **NamedTuple** really useful in practice.  
> If the size of the tuple is small, I can index by integers directly because I can remember the location.  
> If it becomes complicated, I can use **Dict** instead.

`NamedTuple`s are fine when one needs to return multiple values from a function and doesn’t want to create a struct only for this purpose. It’s an on the fly struct.

`Dict`s are slow to lookup, whereas lookup in a named tuple is typically compiled away. With heterogeneous types, using a `Dict` will typically lead to dynamic dispatch, which is devastating for performance.

---

_[View the full topic](https://discourse.julialang.org/t/naming-elements-in-a-matrix/127553)._
