I don't understand why there is that error
# announcements
r
I don't understand why there is that error
s
Parameters cannot be reassigned
l
parameters are considered to be
final
m
Roberto, you only need to create the array inside the function and return it, don’t pass it as a parameter. This way of using mutable “out parameters” is very C-style 🙂
r
yes, cause i know C, C++ and C#
m
Right, there’s no need to do that in Kotlin, just remove the
v
parameter and return the one created inside the function. You can even shorten the declaration to:
Copy code
fun loadArray(n: Int) = IntArray(n) {/*...*/}
function expressions and type inference can help shortening the code