random

Common
JVM
JS
Native
1.3
fun IntRange.random(): Int
(source)
fun LongRange.random(): Long
(source)
fun CharRange.random(): Char
(source)
fun UIntRange.random(): UInt
(source)

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
(source)
fun LongRange.random(random: Random): Long
(source)
fun CharRange.random(random: Random): Char
(source)
fun UIntRange.random(random: Random): UInt
(source)
fun ULongRange.random(random: Random): ULong
(source)

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

Exceptions

IllegalArgumentException - if this range is empty.