Structs

  1. Defining structs
  2. Accessing and updating structs
  3. Structs are bare maps underneath

In chapter 7 we learned about maps:

iex> map = %{a: 1, b: 2}
%{a: 1, b: 2}
iex> map[:a]
1
iex> %{map | a: 3}
%{a: 3, b: 2}

Structs are extensions built on top of maps that provide compile-time checks and default values.