1 iex(3)> a = 2 2 iex(4)> 1 = a ** (MatchError) no match of right hand side value: 2 iex(5)> ^a = 1 ** (MatchError) no match of right hand side value: 1 iex(6)> ^a = 2 2
b, c} = {:hello, "world"} ** (MatchError) no match of right hand side value: {:hello, "world"} def handle_result({:ok, result}), do: IO.puts result def handle_result({:error}), do: IO.puts "Error!"
when is_float(arg), do: round(arg) def handle_result({:ok, result}) when is_string(result) do IO.puts result end def handle_result({:ok, result}) do IO.inspect result end
run on. OTP (Open Telecom Platform): A framework and set of patterns. Processes: lightweight, isolated, concurrent, and distributed. Applications: reusable component, comprised of a set of modules. Supervisor: restarts processes when they crash or fail.
Agent: an abstraction around GenServer with a more usable API. Task: a main form of concurrency in Elixir. Let It Crash: "Rather than write defensive code to handle errors, Erlang/Elixir developers create supervised processes and handle their exit case."
documentation and analysis (not used by the compiler). Behaviors: a way of defining an interface which the implementing module must export (e.g. GenServer, Supervisor).