I would like to read the next n integer from the input stream into an IntArray.
I wrote the code below but as we discussed in Order of init calls in Kotlin Array initialization there is no guarantee that the initialization would start from index 0 and go one by one.
Is there some similarly elegant solution for this which is not based on this possibly false (but as discussed in the other thread in all known implementations true) assumption?
fun Scanner.readIntArray(n: Int): IntArray {
return IntArray(n){nextInt()}
}