random

Common
JVM
JS
Native
1.3
fun IntRange.random(): Int
fun LongRange.random(): Long
fun CharRange.random(): Char
fun UIntRange.random(): UInt
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
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.

Exceptions

IllegalArgumentException - if this range is empty.