Intro

Elixir has a number of types similar to most programming languages.

Integer

Integers are whole numbers.

elixir
# Integers

1
42
100
9001

Float

Floats are decimal place numbers.

elixir
# Floats

1.42
9000.1

Boolean

Booleans are true or false values.

elixir
# Booleans

true
false

Atom

Atoms are constants where the value is the same as the name of the atom. Atoms are similar to symbols in Ruby and are defined with a colon : .

elixir
# Define an atom

:stuff
Note
true, false and nil are also atoms, but they do not need to be prefixed with a colon.

String

String are defined by enclosing characters in double quotes "" and are encoded in UTF-8.

elixir
# Define a string

stuff = "stuff"

# String interpolation

"#{replace_me}"

# Multi-line string

"
Hello im a multi-line string.
"

# Heredoc strings support better formatting for multiple lines

"""
Hello 
im a 
string.
"""

# Sigil format can also be used

~s(I am also a string)

# The capitol sigil format is not interpolated or escaped

~S(#{i_wont_be_replaced} \n im on the same line)
# elixir