2 Building blocks

 

This chapter covers

  • Using the interactive shell
  • Working with variables
  • Organizing your code
  • Understanding the type system
  • Working with operators
  • Understanding the runtime

It’s time to start learning about Elixir. This chapter presents the basic building blocks of the language, such as modules, functions, and the type system. This will be a somewhat lengthy, not particularly exciting, tour of language features, but the material presented here is important because it prepares the stage for exploring more interesting, higher-level topics.

Before starting, make sure you’ve installed Elixir version 1.15 and Erlang version 26. There are several ways to install Elixir, and it’s best to follow the instructions from the official Elixir site at https://elixir-lang.org/install.html.

With that out of the way, let’s start our tour of Elixir. The first thing you should know about is the interactive shell.

2.1 The interactive shell

2.2 Working with variables

2.3 Organizing your code

2.3.1 Modules

2.3.2 Functions

2.3.3 Function arity

2.3.4 Function visibility

2.3.5 Imports and aliases

2.3.6 Module attributes

2.3.7 Comments

2.4 Understanding the type system

2.4.1 Numbers

2.4.2 Atoms

2.4.3 Tuples

Summary