random

inline fun <T> Array<out T>.random(): T(source)
inline fun ByteArray.random(): Byte(source)
inline fun ShortArray.random(): Short(source)
inline fun IntArray.random(): Int(source)
inline fun LongArray.random(): Long(source)
inline fun FloatArray.random(): Float(source)
inline fun CharArray.random(): Char(source)

Returns a random element from this array.

Since Kotlin

1.3

Throws

if this array is empty.


fun <T> Array<out T>.random(random: Random): T(source)

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

Since Kotlin

1.3

Throws

if this array is empty.


inline fun <T> Collection<T>.random(): T(source)

Returns a random element from this collection.

Since Kotlin

1.3

Throws

if this collection is empty.


fun <T> Collection<T>.random(random: Random): T(source)

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

Since Kotlin

1.3

Throws

if this collection is empty.