List ( [ ] )
Try it yourself →An ordered, immutable collection of values.
Syntax
l = [1, 2]; Enum.at(l, 0); length(l); l ++ [x]
Description
Lists are created with square brackets. Enum.at(l, 0) gives the first element (0-indexed), length gives the count. ++ returns a new list (immutable).
Example
l = [1, 2] yeni = l ++ [3] IO.inspect(yeni) IO.puts(Enum.at(yeni, 0)) IO.puts(length(yeni))
Expected output
[1, 2, 3] 1 3
When to use?
Data collections; processing with Enum.