nextBoolean

Common
JVM
JS
Native
1.0
fun nextBoolean(): Boolean

Gets the next random Boolean value.

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

fun main(args: Array<String>) {
//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
}