It's because basically everything in Elixir is a macro :), and the do block is an argument/parameter to that macro:
maybe x do ... end # is really maybe x, do: ... # which ends up being a macro call with a named parameter maybe(x, do: ...)
if x do ... end # is really if x, do: ... # which ends up being a macro call with a named parameter if(x, do: ...)
But it took me a very long to come to grips with this, too :)
It's because basically everything in Elixir is a macro :), and the do block is an argument/parameter to that macro:
Same goes for many (all?) other things in Elixir: And so on.But it took me a very long to come to grips with this, too :)