Hi, I have two numbers that are random, can be neg...
# getting-started
a
Hi, I have two numbers that are random, can be negative, first can be above second or not or even equal. I want to create a range between these two numbers that always have a step of
1
and start always at the lower number, how can I do it in a simple way ?
j
minOf(n1, n2)..maxOf(n1, n2)
?
Or simply
if (n1 < n2) n1..n2 else n2..n1
?
a
oh okay simply, so I created this function
Copy code
fun rangeSorted(first: Int, second: Int) = if (first < second) first..second else second..first