Today I came across a line in a Elixir project that I never saw before:

alias __MODULE__

In simple terms, this aliases the module and makes it available in the namespace.

E.g.

defmodule Some.Nested.Module.Example do
  defstruct ...

  alias __MODULE__

  def some_fun do
    %Example{...}
  end
...
end

🤓 Continue reading