Scala Range

I can't believe we haven't seenRangeyet !

Super easy ! Right ? And so useful and powerful.

Summary of the keywords:

  • to: When you do0 to 3, you will get the numbers0, 1, 2, 3. Notice that the end boundaryis included.
  • until: When you do0 until 3, you will get the numbers0, 1, 2. Notice that the end boundaryis not included.
  • by: When you do0 to 11 by 3, you will get the numbers0, 3, 6, 9. The default value isby 1.
Reveal more information and clues
Load Exercise