https://kotlinlang.org logo
#getting-started
Title
# getting-started
p

Pitel

12/07/2021, 9:23 AM
Is there some way to create range withou having to sort it first? I mean,
10..0
creates empty range, and I have to change it to
10 downTo 0
. But I don't want to bother with it. I would expect
10..0
to do it automaticaly.
s

Stephan Schroeder

12/07/2021, 3:50 PM
you could write your own extension infix function on
Int
to return a range that does the sorting for you.
s

Shawn

12/07/2021, 7:41 PM
making
10..0
step downwards automatically is potentially a pretty sneaky source of bugs. It was expressly decided that range ordering be explicit in order to avoid a footgun
2
☝️ 1
2 Views