Skip to main content


I had no idea functions could be passed around as variables in Elixir :blobcatsweats:
iex(1)> f = fn x -> x*x end
<a class="hashtag" data-tag="function" href="https://gleasonator.com/tag/function">#Function</a>&lt;44.79398840/1 in :erl_eval.expr/5&gt;
iex(2)&gt; is_function(f)
true
iex(3)&gt; f.(4)
16

I know this is a basic feature of most languages, but I’ve been working around it this whole time because I thought it wasn’t possible.
Why's it f.(4) and not f(4) tho?
Anonymous functions in Elixir require the dot. I guess an anonymous function is really a runtime function so it’s different. Idk ask José Valim 😆
¯\_(ツ)_/¯

Terminology nitpick: it's not anonymous anymore when you've assigned it to a variable!
Yeah, I’m starting to think the real difference is runtime vs compile time functions