Atoms In Elixir — Tentamen Software Testing Blog

Image for post
Image for post

TL;DR

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.

Image for post
Image for post

:true and :false are atoms reserved for Boolean value. All logical operators work with those two atoms. You can omit :

Image for post
Image for post

Nil in Elixir is also an atom: :nil == nil

Remember

  • atom naming rules

Originally published at https://blog.tentamen.eu on July 12, 2020.

Written by

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store