Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Elixir Atoms

elixier_notebooks/Atoms.livemd

Elixir Atoms

Section

An atom is a constant whose name is its value. If you’re familiar with Ruby, these are synonymous with Symbols:

:foo
:foo
:foo == :bar
false

The booleans true and false are also the atoms :true and :false, respectively.

is_atom(true)
true
is_boolean(true)
true
true === true
true

Names of modules in Elixir are also atoms. MyApp.MyModule is a valid atom, even if no such module has been declared yet.

defmodule MyApp.MyModule do
end
{:module, MyApp.MyModule, <<70, 79, 82, 49, 0, 0, 4, ...>>, nil}
is_atom(MyApp.MyModule)
true