November 2018
Intermediate to advanced
388 pages
9h 5m
English
Let's write a for loop to print numbers. Consider the code for 8a_ForLoop.kts:
for(num in 1 .. 5){ println(num)}
The output is as follows:

.. is used to specify the range, meaning the program prints numbers from 1 to 5 inclusively.
To exclude a range, the until keyword is used. Consider the code for 8b_ForLoop_Until.kts:
for(num in 1 until 5){ println(num)}
The output is as follows:

If we want to traverse the range in a given step ...
Read now
Unlock full access