randomOf

fun <T> randomOf(vararg options: T, random: Random = Random.Default): T

Returns one of options chosen uniformly at random.

Every argument is equally likely to be returned. The random parameter follows the vararg, so it must be passed by name.

Parameters

options

the candidate values, at least one is required.

random

the source of randomness, Random.Default by default.

Throws