Kotlin Ranges Integral Type Ranges


Example

Integral type ranges ( IntRange , LongRange , CharRange ) have an extra feature: they can be iterated over. The compiler takes care of converting this analogously to Java's indexed for-loop, without extra overhead

for (i in 1..4) print(i) // prints "1234"
for (i in 4..1) print(i) // prints nothing