Add probability to Random.bool()

This commit is contained in:
Abe Pazos
2020-04-09 22:14:39 +02:00
parent 933be5bc9a
commit 5650172820

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 {