3 ms·
How is the inclusive range operator implemented in Kotlin? Something like `for (i in 0..count)` needs to iterate count + 1 times, which may overflow the size of
by ridiculous_fish 9y ago
How is the inclusive range operator implemented in Kotlin? Something like `for (i in 0..count)` needs to iterate count + 1 times, which may overflow the size of count's type - annoying to implement.
- kaeawc 9y agoIn Kotlin it's much more common to write the following, which is exclusive: count.forEach { // do things }
- chc 9y agoI don't see where the overflow would come into play since count is the terminal value and count is necessarily representable in its type.
- coldtea 9y ago>needs to iterate count + 1 times, which may overflow the size of count's type - annoying to implement How's that different from: for (int i=0; i<=count; i++) in e.g. C99?