Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
ridiculous_fish
on May 18, 2017
|
parent
|
context
|
favorite
| on:
Swift is like Kotlin
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.
coldtea
on May 18, 2017
|
next
[–]
>
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?
chc
on May 18, 2017
|
prev
|
next
[–]
I don't see where the overflow would come into play since count is the terminal value and count is necessarily representable in its type.
kaeawc
on May 18, 2017
|
prev
[–]
In Kotlin it's much more common to write the following, which is exclusive:
count.forEach { // do things }
Join us for
AI Startup School
this June 16-17 in San Francisco!
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: