Values and Immutability
- Terms in Elixir. Values are BEAM terms: atoms like :ok, tuples, lists, maps and binaries under new clothes.
- Immutability. Data is immutable: transformation returns new values, and rebinding a name never edits a term.
- Strings are binaries. Elixir strings are UTF-8 binaries: pattern-matchable bytes with proper Unicode functions.
Pattern Matching
- Match operator. The equals sign matches: {:ok, user} = fetch(id) binds by shape or raises honestly.
- Destructuring. Matching destructures everywhere: function heads, case, with: data pulled apart by shape.
- The pin operator. The pin operator matches against an existing value: ^expected = actual asserts, not rebinds.
Functions and Modules
- Modules and def. Code lives in modules: defmodule Billing with def and defp separating public from private.
- Multiple clauses. Functions dispatch across clauses by pattern and guard: control flow in the heads.
- Capture syntax. The capture operator references functions: Billing.total by name, or a short inline form.
Before and after this level
- Before: Start Here: Modern Development on BEAM: Elixir and BEAM, Erlang Compatibility.
- Next: Level 2: Collections: Lists, Tuples and Maps, Enum, Streams.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Elixir Level 1: Elixir Foundations cover?
Values and Immutability, Pattern Matching, Functions and Modules: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Start Here: Modern Development on BEAM, which covers Elixir and BEAM, Erlang Compatibility.