1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 08:08:02 +00:00

Add a note about GC considerations with atoms

This commit is contained in:
jbranchaud
2016-07-07 07:22:26 -05:00
parent ebd901fe9d
commit 38d2833577

View File

@@ -1,15 +0,0 @@
# Dynamically Generating Atoms
> Atoms are constants where their name is their own value.
The use of atoms like `:ok` and `:error` show up all over the place in
Elixir. These are atoms that tend to be statically defined. Atoms can also
be dynamically defined using string interpolation.
For example, I can generate a handful of atoms by mapping over a range of
integers.
```elixir
> Enum.map(1..5, &(:"some_atom_#{&1}"))
[:some_atom_1, :some_atom_2, :some_atom_3, :some_atom_4, :some_atom_5]
```