Syntax
Tuples
{:a, 2, :foo}
is the same as {a: 2, :foo}
. {:a, 2} |> elem(0) == :a
Maps
%{a: 1, b: 2}
is the same as %{:a => 1, :b => 2}
. %{a: 1, b: 2}[:a] == 1
Lambdas
&1
is the same as fn x -> x end
Conditionals
if
/else
are truthy
and falsy
def
guards, cond
and case
- pattern matching are strict true
/ false
, that’s why they’re more efficient.
Also, remember that everthing but false
and nil
is truthy.
Strings and Charlist
don’t forget the ?a == ~c"a" |> Enum.at(0)
the Charlist, which differs from the string
Lists
Also, always prepend, avoid appending [a,b,c | rest]
Enum
This is the default module with mathematical Group operations.