Elixir Language Atoms


Example

Atoms are constants that represent a name of some thing. The value of an atom is it's name. An atom name starts with a colon.

:atom   # that's how we define an atom

An atom's name is unique. Two atoms with the same names always are equal.

iex(1)> a = :atom
:atom

iex(2)> b = :atom
:atom

iex(3)> a == b
true

iex(4)> a === b
true

Booleans true and false, actually are atoms.

iex(1)> true == :true
true

iex(2)> true === :true
true

Atoms are stored in special atoms table. It's very important to know that this table is not garbage-collected. So, if you want (or accidentally it is a fact) constantly create atoms - it is a bad idea.