choices

@JvmName(name = "choicesVararg")
@JvmOverloads
fun <T> Random.choices(vararg elements: T, weights: List<Int>? = null, length: Int = 1): List<T>

Returns a random list from this array using the specified source of randomness.

Since

1.1.0

Return

randomness list

Parameters

elements
weights

A list were you can weigh the possibility for each value. (Optional)

length

An integer defining the length of the returned list. (Optional)

See also

Throws

IllegalArgumentException

if this array is empty.


@JvmOverloads
fun <T> Random.choices(array: Array<T>, weights: List<Int>? = null, length: Int = 1): List<T>

Returns a random list from this array using the specified source of randomness.

Since

1.1.0

Return

randomness list

Parameters

array
weights

A list were you can weigh the possibility for each value. (Optional)

length

An integer defining the length of the returned list. (Optional)

See also

Throws

IllegalArgumentException

if this array is empty.


@JvmOverloads
fun <T> Random.choices(collection: Collection<T>, weights: List<Int>? = null, length: Int = 1): List<T>

Returns a random list from this collection using the specified source of randomness.

Since

1.1.0

Return

randomness list

Parameters

collection
weights

A list were you can weigh the possibility for each value. (Optional)

length

An integer defining the length of the returned list. (Optional)

See also

Throws

IllegalArgumentException

if this collection is empty.