by Example

Values


Integer and floats



Strings


Charlists (charlists are lists of codepoints)


Booleans


Atoms (atoms are not garbage collected)


Lists


Tuples


Maps (keys are atoms)


Maps (keys are strings)


Bitstrings and Binaries


References


A function is a value too

IO.inspect(2)
IO.inspect(2.3)


IO.inspect("Hola! I'm a string.")


IO.inspect('ABC')


IO.inspect(false and true)


IO.inspect(:ok)


IO.inspect([1, 2, 3])


IO.inspect({:a, "two", 3})


IO.inspect(%{name: "John Doe", age: 23})


IO.inspect(%{"name" => "Jane Doe", "age" => 23})


IO.inspect(<<1, 2, 3>>)


IO.inspect(make_ref())


IO.inspect(fn x -> x + 1 end)
$ elixir values.exs
2
2.3
"Hola! I'm a string."
'ABC'
false
:ok
[1, 2, 3]
{:a, "two", 3}
%{age: 23, name: "John Doe"}
%{"age" => 23, "name" => "Jane Doe"}
<<1, 2, 3>>
#Reference<0.366004037.2573467655.125521>
#Function<0.38557874 in file:src/code/values.exs>


Next: Variables