Search⌘ K

Default Parameters

Explore how to define and use default parameters in Elixir named functions. Learn how Elixir matches function arguments with default values, how to avoid conflicts with pattern matching, and understand the behavior of passing different numbers of arguments.

We'll cover the following...

Default parameters

When we define a named function, we can give a default value to any of its parameters by using the syntax param \\ value. When we call a function that’s defined with default parameters, Elixir compares the number of arguments we’re passing with the number of required parameters for the function.

  • If we’re passing fewer arguments than the number of required parameters, then there’s ...