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, label: "This is a float")


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
This is a float: 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.3656494687.702545923.165208>
#Function<0.129133685 in file:src/code/values.exs>


Next: Variables