# random

Jason Zhao

03/20/2024, 12:24 AM
So I noticed something with the ranges in Kotlin.. If
exists, why not`<..` and
? Currently if I write
a >= b && a <= c
the IDE will tell me to replace it with
a in b..c
if I write
a >= b && a < c
then IDE will not recommend me with anything, but I can still write
a in b..<c
and this would be correct, though I'm not sure whether it's optimized by the compiler like the first case. however, if I write
a > b && a < c
there is no way to represent it in ranges if I wanted to! I find this bit of inconsistency to be a little annoying. Ideally all four operators should be present and optimized by the compiler.
💯 3


03/20/2024, 12:37 AM
I really would love it to match the math operators

Alex Kuznetsov

03/21/2024, 8:48 PM
OTOH it would allow to implement algebra on ranges, such as +, -, * and such, similar to RangeMap in guava
there are multiple uses for ranges besides just loops


03/21/2024, 8:49 PM
interval trees are cool but require a different data structure