Skip to main content
← Elixir & OTP Pattern Matching

Pick a value

Function clauses

def handle({:ok, result}), do: {:success, result}
def handle({:error, reason}), do: {:failure, reason}
def handle([head | tail]), do: {:list, head, tail}
def handle(%{name: name}), do: {:named, name}
def handle(other), do: {:unknown, other}

Select a value to see pattern matching in action