do Supervisor.start_link(__MODULE__, :ok, name: name) End def init(:ok) do children = [ supervisor(ExBees.Map.Segment, [ExBees.Map.Segment]) ] supervise(children, strategy: :one_for_one) end end
{4, 5, 6} -> ...> "This clause won't match" ...> {1, x, 3} -> ...> "This clause will match and bind x to 2 in this clause" ...> _ -> ...> "This clause would match any value" ...> end "This clause will match and bind x to 2 in this clause"
an operating system one!) spawn_link(fn -> send current_process, {:msg, "hello world"} end) # Block until the message is received receive do {:msg, contents} -> IO.puts contents end
-> io:format('~s~n', ['Hello world!']). % This one works only with lists some_fun(List) when is_list(List) -> io:format('~s~n', List). % Non-exported functions are private priv() -> secret_info. defmodule HelloModule do # A "Hello world" function def some_fun do IO.puts "Hello world!" end # This one works only with lists def some_fun(list) when is_list(list) do IO.inspect list end # A private function defp priv do :secret_info end end
A = 1. 1 2> A = 2. ** exception error: no match of right hand side value 2 3> io:format("~p", [A]). 1ok ~ iex Interactive Elixir (1.4.1) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> a = 1 1 iex(2)> a = 2 2 iex(3)> IO.puts a 2 :ok