Atoms In Elixir — Tentamen Software Testing Blog
In the previous post, we explained Elixir Numbers. Today we discuss Elixir literal named constants, atoms. This post is part of the functional language series, and it is based on the remarkable book Elixir In Action by Sasa Juric.
We use atoms as constants that we assign to variables. Atom name consists of alphanumeric characters with
_. We can also have an atom with spaces. Atom table is a table in BEAM where all atoms are stored. If two variables have the same atom value, they share that value. Doing that, Elixir’s programs are efficient regarding memory and performance.
Atom alias is when you name something with the first uppercase letter.
:false are atoms reserved for Boolean value. All logical operators work with those two atoms. You can omit
Nil in Elixir is also an atom:
:nil == nil
- atom naming rules
- atoms with spaces
- why are atoms efficient
- atom table
falseare atoms because there is no Boolean type in Elixir
nilis also an atom
Originally published at https://blog.tentamen.eu on July 12, 2020.