A colleague of mine found out that you can define functions with their function name in parentheses and Elixir will create a function with arity 0 out of it. An example:
defmodule A do
def (foo) do
IO.inspect("called")
:bar
end
end
iex> A.foo()
"called"
:bar
iex> A.__info__(:functions)
[foo: 0]
I’ve never seen this syntax. Can somebody explain why and how this works, please?