What is a function/2 prefixed by ambersand (&) mean?

I see in some places a function along with its arity is prefixed by & like &function/3. Can I know what this means or how this works? I understand the usage of & in anonymous functions but this case is not clear to me.

And I also see in some cases an anonymous function is suffixed by a parentheses like this (fn x -> {:ok, x} end).(). What does this mean?

Modules and functions - The Elixir programming language, the “Function capturing” section.

The official tutorial is small and to the point, I recommend going through it.


It’s used when you want to pass function as a parameter

1 Like

There are also docs for it: Kernel.SpecialForms — Elixir v1.12.3