Merge pull request #75 from hamoid/randomBoolProbability

Add probability to Random.bool()
This commit is contained in:
Edwin Jakobs
2020-04-10 13:57:20 +02:00
committed by GitHub

View File

@@ -71,8 +71,8 @@ object Random {
return rnd.nextInt(min, max)
}
fun bool(): Boolean {
return rnd.nextBoolean()
fun bool(probability: Double = 0.5): Boolean {
return rnd.nextDouble(1.0) < probability
}
fun <T> pick(coll: Collection<T>): T {