Use keyword lists for 'options'-style parameters that contains multiple key-value pairs:
def myfunc(arg1, opts \\ []) do
# Function body
end
We can call the function above like so:
iex> myfunc "hello", pizza: true, soda: false
which is equivalent to:
iex> myfunc("hello", [pizza: true, soda: false])
The argument values are available as opts.pizza
and opts.soda
respectively.
Alternatively, you could use atoms: opts[:pizza]
and opts[:soda]
.