Ranges

Ranges, again, similar to what happens in Ruby, represent an interval between two integers. To create a range, we use this:

iex> 17..2117..21iex> 19 in 17..21true

Similar to what we do with a list, we can use the in operator to check whether a number is between the start and the end of a range.

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.