.. for upward closed ranges,
downTo for downward closed ranges, and
until for upward half-open ranges.
I’d like to propose a new
downUntil function for the only missing combination: downward half-open ranges. For example,
for (i in 4 downUntil 0) print(i) would print “4321”.
(At Duolingo we disallow
downTo for consistency since none of our other programming languages use closed ranges. This leaves the rather awkward
(lastNum until firstNum + 1).reversed() as our internal recommendation for downward ranges in Kotlin.)