So I noticed something with the ranges in Kotlin.....
# random
j
So I noticed something with the ranges in Kotlin.. If
..
and
..<
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
p
I really would love it to match the math operators
a
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
e
interval trees are cool but require a different data structure