The functions rangeTo and downTo are complementary with respect to the ranges produced: ('a'.rangeTo('d')).joinToString(",") // creates "a,b,c,d" It’s recommended to use the until function over an open range (see loops on ranges): for (i in 0.n - 1) // bad The until function creates a range including the lower and excluding the upper limit. While the double dot operator creates a range including the lower and upper limit,
There are 4 main ways to create ranges in Kotlin: This post is about options how to create Kotlin ranges. However, you can define ranges without upper limit included. The range definition states: it is defined by its two endpoint values which are both included in the range. A Kotlin range is a series of consecutive items between defined lower and upper limits.