This only works for the module in which the alias is defined, for example:
defmodule A do
alias A.B, as: C
defmodule B do
defstruct name: ""
end
def new do
%C{}
end
end
Then you can:
iex(6)> A.new
%A.B{name: ""}
This will also work in iex if you enter an alias there:
iex(7)> alias A.B, as: C
nil
iex(8)> %C{}
%A.B{name: ""}
source
share