Add probability to Random.bool()
This commit is contained in:
@@ -71,8 +71,8 @@ object Random {
|
|||||||
return rnd.nextInt(min, max)
|
return rnd.nextInt(min, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bool(): Boolean {
|
fun bool(probability: Double = 0.5): Boolean {
|
||||||
return rnd.nextBoolean()
|
return rnd.nextDouble(1.0) < probability
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> pick(coll: Collection<T>): T {
|
fun <T> pick(coll: Collection<T>): T {
|
||||||
|
|||||||
Reference in New Issue
Block a user