random

inline fun IntRange.random(): Int
inline fun LongRange.random(): Long
inline fun CharRange.random(): Char

Returns a random element from this range.

Since Kotlin

1.3

Throws

if this range is empty.


fun IntRange.random(random: Random): Int
fun LongRange.random(random: Random): Long
fun CharRange.random(random: Random): Char

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

Since Kotlin

1.3

Throws

if this range is empty.


inline fun UIntRange.random(): UInt
inline fun ULongRange.random(): ULong

Returns a random element from this range.

Since Kotlin

1.5

Throws

if this range is empty.


fun UIntRange.random(random: Random): UInt
fun ULongRange.random(random: Random): ULong

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

Since Kotlin

1.5

Throws

if this range is empty.