defmodule Calc do
def sum(a, b) do
a + b
end
end
# And we call it elsewhere as:
# Calc.sum(2, 3)
# => 5
Tooling
Mix - build tool: tasks for creating, compiling, testing, manages dependencies, more
ExUnit - Test unit framework
IEx - REPL
Hex - Package Manager
OTP - Set of libraries that ships w/ Erlang. Used to build robust, fault-tolerant applications
# In Elixir, the = operator is actually called the match operator
iex> x = 1
1
iex> 1 = x
1
iex> 2 = x
** (MatchError) no match of right hand side value: 1
# In Elixir, the = operator is actually called the match operator
iex> x = 1
1
iex> 1 = x
1
iex> 2 = x
** (MatchError) no match of right
hand side value: 1