published: 29th of January 2021
Elixir has a number of types similar to most programming languages.
Integers are whole numbers.
# Integers
1
42
100
9001
Floats are decimal place numbers.
# Floats
1.42
9000.1
Booleans are true or false values.
# Booleans
true
false
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 : .
# Define an atom
:stuff
String are defined by enclosing characters in double quotes "" and are encoded in UTF-8.
# 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)
https://elixir-lang.org/getting-started/basic-types.html
https://elixir-lang.org/crash-course.html#data-types
https://learning.oreilly.com/library/view/elixir-in-action/9781617295027/c02.xhtml