elixir function pattern matching
iex> handle_result = fn ...> {:ok, result} -> IO.puts "Handling result..." ...> {:ok, _} -> IO.puts "This would be never run as previous will be matched beforehand." ...> {:error} -> IO.puts "An error has occurred!" ...> end iex> handle_result.({:ok, some_result}) # Handling result... iex> handle_result.({:error}) # An error has occurred!