Short Elixir note — Module and Atom
Sep 8, 2018 · 1 min read
In Elixir world, I almost get inspired every day. I will keep writing a short note to explain some of the interesting topics from day to day.
Module as an atom ?
We always call a module function with the following format.
defmodule Hi do
def my_name_is(), do: "tngan"
endHi.my_name_is() # "tngan"
As we know, Elixir has a great interoperability with Erlang libraries. Therefore, we can call the function with an atom. It might confuse the newbie that the type of:string.
:string.trim "test " # output is "test"In fact, we can use iex to check this out.


Yeah, so the module is an atom with a prefix Elixir in order to differentiate the module from Erlang libraries. In other words, the Elixir module function can be called via:
:"Elixir.Hi".my_name_is() # "tngan"