nextBoolean

fun Random.nextBoolean(probability: Double): Boolean

Returns true with the given probability and false otherwise.

A probability of 0.0 always yields false and a probability of 1.0 always yields true; values in between follow a Bernoulli distribution.

Parameters

probability

the chance of returning true, must be within 0.0..1.0.

Throws

if probability is NaN or outside 0.0..1.0.