`for` Loops

Learn about Kotlin's `for` loops to iterate over any iterable structure, and how to build ranges for iteration.

In contrast to while loops, Kotlin’s for loops work a bit differently than you may be used to from other languages.

for Loops #

Kotlin’s for loops are different from many other languages because they’re used in the same manner as for-each loops (or for-in loops). Thus, you always give an iterable to the for loop over which it iterates:

Get hands-on with 1400+ tech skills courses.