alias is lexically scoped
Aliases are lexically scoped, allowing you to alias a module inside of a function and that alias will only exist in that function's scope. Also TIL: You can even alias over Elixir standard lib module names.
defmodule Cartography do
def north_america do
alias Earth.NorthAmerica.Map
#Map is now Earth.NorthAmerica.Map
# You can get to the normal Map module using Elixir.Map
end
def foo do
#Map is still Elixir.Map
end
end
Tweet