Modules
Understand nested modules and different kinds of directives in Elixir.
Modules provide namespaces for things we define. They also act as wrappers for macros, structs, protocols, and other modules. If we want to reference a function defined in a module from outside that module, we need to prefix the reference with the module’s name. We don’t need that prefix if code references something inside the same module as itself, as in the below example.
Run the Mod.func1
or Mod.func2
commands in the terminal below. Don’t forget to start an iex
session first with the iex -S mix
command.
Get hands-on with 1400+ tech skills courses.