Mike
05/05/2019, 1:08 PMDico
05/05/2019, 2:08 PMuntil or a..b-1
Personally, I find it very frustrating, I think .. should represent an exclusive range because of the use case being so much more common. It's counter intuitive with the style of indices starting at 0 rather than 1.
But the window to change it has long faded.karelpeeters
05/05/2019, 2:55 PMsubList, random.nextInt, the most common for loop is 0, size exclusive, etc. I like what Rust did more, .. is exclusive and ..= is inclusive. Too late to change now 🤷♂️Mike
05/05/2019, 2:55 PMghedeon
05/05/2019, 4:04 PM<
Swift: 0...5 & 0..<5
I like it even more than Rust versionDico
05/07/2019, 2:03 PMDico
05/07/2019, 2:07 PMrepeat function if this design were the other way around.Mike
05/07/2019, 2:21 PMkarelpeeters
05/07/2019, 2:22 PMrepeat(10) { println(it) } is 0 to 10 exclusive too.Mike
05/07/2019, 2:36 PMrepeat passed an index in… Obviously it would be non-intuitive if it was inclusive as it would repeat n+1 times.ghedeon
05/07/2019, 3:21 PMDico
05/08/2019, 8:03 PMDico
05/08/2019, 8:06 PMoperator fun until right?Dico
05/08/2019, 8:09 PMrepeat(10) { i -> and for (i in 0..10) {
I would prefer to write the latter, but the problem is that it's not the same. I'd have to write for (i in 0 until 10) { even though the exclusive range provided by until is a much more common use case.Dico
05/08/2019, 8:12 PMMike
05/08/2019, 8:45 PMrepeat passes in the index, I wouldn’t be inclined to use for (i in 0..9) rather than repeat(10). But I agree it’s subjective, and support submitting a KEEP if you feel that strongly about it. Ultimately, it’s up to the Language team to decide.Dico
05/08/2019, 8:46 PMkarelpeeters
05/08/2019, 10:19 PMDico
05/08/2019, 10:57 PM