nextFloat
Gets the next random Float value uniformly distributed between 0 (inclusive) and 1 (exclusive).
Since Kotlin
1.3Samples
import kotlin.math.sin
import kotlin.random.Random
import kotlin.test.assertTrue
fun main() {
//sampleStart
if (Random.nextFloat() <= 0.3) {
println("There was 30% possibility of rainy weather today and it is raining.")
} else {
println("There was 70% possibility of sunny weather today and the sun is shining.")
}
//sampleEnd
}