Scala Range

I can't believe we haven't seen Range yet !

Super easy ! Right ? And so useful and powerful.

Summary of the keywords:

  • to: When you do 0 to 3, you will get the numbers 0, 1, 2, 3. Notice that the end boundary is included.
  • until: When you do 0 until 3, you will get the numbers 0, 1, 2. Notice that the end boundary is not included.
  • by: When you do 0 to 11 by 3, you will get the numbers 0, 3, 6, 9. The default value is by 1.
Reveal more information and clues
Load Exercise