How to convert an Array<Int> into an IntArray?



I was wondering if there is an easy way to convert an Array<Int> into an IntArray? The background is that the array-helper returns an Array<Int>, but the function I have to call requires an IntArray.

fun test(values: IntArray) { ... } val values = array(1, 2, 3) test(values) // does not work

Kind regards, Philipp


I think there should be such a function in the standard library, if there isn't, feel free to contribute or file an issue


Ok, thanks. I'll check again.


In your example you can just use intArray function. And for converting we don't have any function, and I create issue, feel free to vote and/or contribute.


Great! intArray was what I was looking for. Thanks


I had a look into the code when looking at the described problem and in Array.kt I found this:

public class Array<reified T>( ...) { }

I wonder what the meaning of reified is. Are there any plans about reified types?

Regards, Oliver


This simply reflects the nature of JVM arrays which are indeed reified