Advanced Module Keywords
You won’t get too far into an Elixir application without seeing one of the following keywords: alias, require, import, or use. They all serve different purposes and are extensively used in Elixir modules. We’ll go over each of them, including when you would use each.
Each of these module keywords can be used as many times as you want in a module. For example, you could alias two modules, require another, and use three more.
This section uses examples that won’t actually compile, so you don’t need to type them out. They’re here to illustrate how the various keywords are used.
Alias
As you create your application, you will have long module names like MyApp.Widgets.Query.WidgetStore. Long module names allow you to cleanly ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access