Private Functions

Understand private functions and usage of the pipe operator in Elixir.

The defp macro defines a private function, one that can be called only within the module that declares it. We can define private functions with multiple heads, just as we can with def. However, we can’t have some heads private and others public. That is, the following code is invalid:

def fun(a) when is_list(a), do: true 
defp fun(a), do: false

Get hands-on with 1200+ tech skills courses.