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 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 PMoperator fun until
right?repeat(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.Mike
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