Um, I just wanted to try the new random implementa...
# kotlin-native
a
Um, I just wanted to try the new random implementation in K/N:
Copy code
fun main(args: Array<String>) {
    val ls = listOf(12, 23, 435).shuffled()
    println(ls[0])
}
I have been using this code, and got that output
Copy code
Uncaught exception from Kotlin's main: kotlin.IndexOutOfBoundsException
        at kfun:kotlin.Exception.<init>()kotlin.Exception (0x4068b2)
        at kfun:kotlin.RuntimeException.<init>()kotlin.RuntimeException (0x4067e2)
        at kfun:kotlin.IndexOutOfBoundsException.<init>()kotlin.IndexOutOfBoundsException (0x406762)
        at kfun:kotlin.collections.ArrayList.checkIndex#internal (0x40de44)
        at kfun:kotlin.collections.ArrayList.get(<http://kotlin.Int|kotlin.Int>)#GENERIC (0x40feb7)
        at kfun:kotlin.collections.shuffle@kotlin.collections.MutableList<#GENERIC>.()Generic (0x41b89f)
        at kfun:kotlin.collections.shuffled@kotlin.collections.Iterable<#GENERIC>.()Generic (0x41c109)
        at kfun:main(kotlin.Array<kotlin.String>) (0x403e85)
        at EntryPointSelector (0x403d06)
        at Konan_start (0x403c77)
        at Konan_run_start (0x403bf2)
        at Konan_main (0x403b67)
        at __libc_start_main (0x7f57da6f0b97)
        at  (0x403a0a)
        at  ((nil))
a
a
If I am running it multiple times, sometimes it crashes, is that because it generates random number?
Copy code
fun main(args: Array<String>) {
    val ls = mutableListOf(12, 23, 435).shuffled()
    println(ls[0])
}
a
Looks like it, yeah
a
Welp, the API is broken, will there be a fix in 0.9?
a
Please read the Github issue, this is already fixed in dev version of compiler and will be fixed in 0.9
a
Ok thanks, got it
p
This issue is fixed also in 0.8.1
a
Great!