nextBoolean

Gets the next random Boolean value.

Since Kotlin

1.3

Samples

import kotlin.math.sin
import kotlin.random.Random
import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   val presents = listOf("Candy", "Balloon", "Ball")
// a random partition, the result may be different every time
val (alicePresents, bobPresents) = presents.partition { Random.nextBoolean() }

println("Alice receives $alicePresents")
println("Bob receives $bobPresents") 
   //sampleEnd
}