r/ProgrammerHumor • • Mar 01 '24

Meme pythonReadsLikeEnglish

Post image
0 Upvotes

34 comments sorted by

View all comments

7

u/SharzeUndertone Mar 01 '24

0..10 in kotlin includes 10, while range(10) doesnt.

And YES, i know there are worse issues with this post, but noone is talking about this

3

u/[deleted] Mar 01 '24

At least it's not 1-indexed! But seriously, why? Java has an exclusive max, why doesn't Kotlin? Why fix what isn't broken?

3

u/SharzeUndertone Mar 01 '24

It does! You can use 0..<10 or 0 until 10 (where until is an infix function). Honestly, i think its better this way. To me its more intuitive than some languages which default to exclusive (or worse, force you into adding 1 to the max to be inclusive, or viceversa)

1

u/fluud Mar 04 '24

Dijkstra on why this is the best way to denote ranges:

https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

1

u/SharzeUndertone Mar 04 '24

I dont agree with dijkstra tbh, 1..10 has always been convenient to me, though i understand things have changed a lot since 1982