Tutorial by Examples

The Pipe Operator |> takes the result of an expression on the left and feeds it as the first parameter to a function on the right. expression |> function Use the Pipe Operator to chain expressions together and to visually document the flow of a series of functions. Consider the following:...
Parentheses are needed to avoid ambiguity: foo 1 |> bar 2 |> baz 3 Should be written as: foo(1) |> bar(2) |> baz(3)
There are two kinds of boolean operators in Elixir: boolean operators (they expect either true or false as their first argument) x or y # true if x is true, otherwise y x and y # false if x is false, otherwise y not x # false if x is true, otherwise true All of booleans...
Equality: value equality x == y (1 == 1.0 # true) value inequality x == y (1 != 1.0 # false) strict equality x === y (1 === 1.0 # false) strict inequality x === y (1 !== 1.0 # true) Comparison: x > y x >= y x < y x <= y If types are compatible, comparison uses natural o...
You can join (concatenate) binaries (including strings) and lists: iex(1)> [1, 2, 3] ++ [4, 5] [1, 2, 3, 4, 5] iex(2)> [1, 2, 3, 4, 5] -- [1, 3] [2, 4, 5] iex(3)> "qwe" <> "rty" "qwerty"
in operator allows you to check whether a list or a range includes an item: iex(4)> 1 in [1, 2, 3, 4] true iex(5)> 0 in (1..5) false

Page 1 of 1