4 ms·
> the useless do at the end of almost every defsomething declarations (the compiler should get it by itself.) That's actually one of the things I personally lo
by yellowapple 10y ago
> the useless do at the end of almost every defsomething declarations (the compiler should get it by itself.)
That's actually one of the things I personally love about Elixir relative to other Ruby-like-syntax languages (including Ruby itself). Sure, it might technically be extraneous and unnecessary, but it's a nice bit of consistency. Why shouldn't def and defmodule and what have you not be ordinary statements that take a block as an argument?
This is, in fact, consistent with the 'def foo, do: bar' shorthand format in Elixir (and related shorthands like 'if foo, do: bar, else: baz'). No need to have a bunch of different statements that can start a new scope when it's just three more characters to throw a ' do' at the beginning of each of them. Consistent and clear.