voddan
08/05/2017, 6:06 AM..
is made so to emulate the traditional for
loop. In a code for(int i = A; i < B; i++){}
nothing happens if A
is greater than B
. This is how programmers are accustomed to think about iterations. If the ..
loop worked both ways, the number of bugs would be colossal.horse_badorties
08/05/2017, 8:17 AM3..1
returning an IntRange
with step = 1
rather than -1
is un-intuitive and I'm quite sure I'm not alone.
How is 2 in 3..1 == false
intuitive? Or "d" in "z".."a" == false
?
When would it ever make sense to use 3..1
anyway?
Your argument is a bit like saying when
should fall-through because that's how programmers are accustomed to think about switch..case
🙂
I believe kotlin rookies (like me) falling for this will outnumber those who intuitively expect the current behaviour and I second @kevinmost's suggestion to at least add a lint warning.voddan
08/05/2017, 11:05 AMvoddan
08/05/2017, 11:09 AMfor(i = A; i < B; i++)
and A <= x && x <= B
constructs was more important than anything else.voddan
08/05/2017, 11:11 AMstart in calculateLeft()..calculateRight()
kevinmost
08/05/2017, 2:53 PM