Want to learn?

Ranges

Representation

Documentation

The range is a discrete number of values where the first and last values are integers separated with two dots. It can be either increasing or decreasing. In most cases, you can make use of it whenever you need to iterate over a set of numbers.

iex> 1..5
1..5
iex> 5..1
5..1

It's worth to note that both ends of the range are also a part of it:

iex> range = 1..5
1..5
iex> Enum.member? range, 1
true
iex> Enum.member? range, 5
true

Start a project with your dedicated software house

Top

Contact us

* Required fields

Elo Mordo!Elo Mordo!