Lists

Understand how lists are used for pattern matching and variable binding.

Elixir lists can be created using square brackets containing a comma-separated set of values. It performs pattern matching. A pattern (the left side) is matched if each term in the pattern can be matched to the corresponding term in the values. A literal value in the pattern matches that exact value, and a variable in the pattern matches by taking on the corresponding value. See the below example.

Get hands-on with 1200+ tech skills courses.