``` fun tests(start: Int, end: Int): IntArray = (...
# functional
s
Copy code
fun tests(start: Int, end: Int): IntArray =
 (start until end).toList().toIntArray()
h
thanks, so I have to convert it to a
List
first and then
Array
? Isn't that expensive?
s
Ye, it's how Kotlin collections work unfortunately. In
Scala
they have a special system with implicit classes which makes it more flexible.
toArray
is defined on
Collection
so only way to do it without writing any custom code is this. If you are worried about performance I would definitely write a custom extension method on
IntRange
to convert
toIntArray
directly.
h
thanks @simon.vergauwen
s
Anytime :)