Multiple Return Values in Elixir
Elixir has built-in support for multiple return values. This feature is used often in idiomatic Elixir, for example to return both result and error values from a function.
To run the program:
In Elixir, functions that return multiple values typically return them as tuples. Pattern matching is used to extract the values from the tuple. This is similar to multiple assignment in some other languages.
The underscore _
in Elixir serves a similar purpose to the blank identifier in some other languages. It’s used when you want to ignore a value in pattern matching.
Accepting a variable number of arguments is another nice feature of Elixir functions; we’ll look at this next.