April 2024
Beginner to intermediate
224 pages
5h 7m
English
Lists contain data and can be enumerated on. On the surface, they are similar to Ruby arrays, but there are pretty significant differences under the hood that result in totally different performance characteristics. As a result, you’ll use lists differently in Elixir than you would in Ruby.
In addition to lists, there’s a list alternative that throws a bit of a wrench at new Elixir programmers. You’ll learn about tuples and how they differ from lists. Don’t worry though, it’s a pretty straightforward difference.
Lists are represented with the bracket [] syntax. You can easily create them, add to them, and work with them just as in Ruby. Enter the following code in an IEx session:
| | $ iex |
| | iex> list = [1, 2, 3] |
| |
Read now
Unlock full access