choicesOrNull

@JvmOverloads
fun <T> Random.choicesOrNull(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, or null if this array is empty.

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


@JvmOverloads
fun <T> Random.choicesOrNull(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, or null if this collection is empty.

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