random

Common
JVM
JS
Native
1.3
fun IntRange.random(): Int
fun LongRange.random(): Long
fun CharRange.random(): Char
@ExperimentalUnsignedTypes fun UIntRange.random(): UInt
@ExperimentalUnsignedTypes fun ULongRange.random(): ULong

Returns a random element from this range.

Exceptions

IllegalArgumentException - if this range is empty.

Common
JVM
JS
Native
1.3
fun IntRange.random(random: Random): Int
fun LongRange.random(random: Random): Long
fun CharRange.random(random: Random): Char
@ExperimentalUnsignedTypes fun UIntRange.random(
    random: Random
): UInt
@ExperimentalUnsignedTypes fun ULongRange.random(
    random: Random
): ULong

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

Exceptions

IllegalArgumentException - if this range is empty.