next Boolean
Версия Kotlin: 1.3
open fun nextBoolean(): Boolean
Возвращает следующее случайное значение типа Boolean.
Примеры
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
}
© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.random/-random/next-boolean.html