A range represents a sequence of numbers between a start and an end. Elixir provides dedicated range syntax, membership testing with in, and enumeration through Enum. section 2.4.11
Ranges are useful because they:
- Represent boundaries without storing every value. section 2.4.11
- Keep a small, constant memory footprint, even for a million-number range. section 2.4.11
- Work directly with Enum functions as enumerable values. section 2.4.11
Membership and enumeration
Define a range with 1..2, test membership with 2 in range, or pass 1..3 to Enum.each/2 to print its values. section 2.4.11
iex(4)> Enum.each(
1..3,
&IO.puts/1
)
1
2
3
Inspect a runnable Enum.each example that iterates through a range. section 2.4.11






