What's stopping JB from adding functionality like ...
# announcements
h
What's stopping JB from adding functionality like this:
3..0 // 3, 2, 1, 0
?
i
The cases where range ends are not constant, e.g.
0..indexOf(substring)
. If the substring is missing, getting an empty range would be more predictable than getting a range going from zero to -1.
h
hmm, so are you saying it's very unlikely the functionality i want will be added?
could a different operator, e.g.
...
be added?
maybe even python's
:
i
In the form
3..0
— it's unlikely, but maybe you could find another syntactic option for that feature.
h
i do wonder why `indexOf`returns a
-1
if it finds nothing instead of
null
. The latter would play so much better with kotlin's null safety.
i
Yeah, but then you'll have to pay price for boxing each time you want to find an index.
h
i imagine if the world were perfect, JB would change that function to be nullable, but since that would break so many legacy systems, it's basically never going to happen
my dreams are dashed!
g
What's wrong with
3 downTo 0
? Maybe I just do not use ranges often to wish separate operator, but all set of range infix functions works really well for me, also it much more easy to understand especially for new comers than full set of range operators imo
h
it's unnecessarily verbose
in many occassions
g
¯\_(ツ)_/¯
And oeprators are cryptic and must be a part of the language, trade-offs are everywhere
l
downTo
has the benefit of being explicit, and we know that
..
is always an incrementing range
☝🏽 1