# Why does \`elem/2\` exist?

**URL:** <https://forum.elixirforum.com/t/why-does-elem-2-exist/64854>\
**Category:** Questions\
**Tags:** functions\
**Created:** [July 11, 2024, 3:04am UTC](https://forum.elixirforum.com/t/why-does-elem-2-exist/64854 "2024-07-11T03:04:54Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![dorgan](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dorgan/32/22107_2.png) [@dorgan](https://forum.elixirforum.com/u/dorgan)\
**Post date:** [July 11, 2024, 3:23am UTC](https://forum.elixirforum.com/t/why-does-elem-2-exist/64854/3 "2024-07-11T03:23:17Z")

</div>

- You have tuples, a fixed size array of elements.
- You can access them by a random index.
- There is no syntax to access a random index of a tuple
- Pattern matching requires you to know the length of the tuple up-front

I think it makes sense to have such a function be part of the standard library. The reasoning is quite simple: if you provide a builtin data structure, it makes sense to provide an API to read and write to it.

Wether or not it’s idiomatic to access a random element of a tuple is a whole different topic.

---

_[View the full topic](https://forum.elixirforum.com/t/why-does-elem-2-exist/64854)._
