Package-level declarations

Provides the default generator of pseudo-random values, the repeatable generator, and a base class for other RNG implementations.

Provides the default generator of pseudo-random values, the repeatable generator, and a base class for other RNG implementations.

Types

Link copied to clipboard
abstract class Random

An abstract class that is implemented by random number generator algorithms.

Since Kotlin 1.3

Functions

Link copied to clipboard

Creates a java.util.Random instance that uses the specified Kotlin Random generator as a randomness source.

Since Kotlin 1.3
Link copied to clipboard

Creates a Kotlin Random instance that uses the specified java.util.Random generator as a randomness source.

Since Kotlin 1.3
Link copied to clipboard
fun Random.nextInt(range: IntRange): Int

Gets the next random Int from the random number generator in the specified range.

Since Kotlin 1.3
Link copied to clipboard

Gets the next random Long from the random number generator in the specified range.

Since Kotlin 1.3
Link copied to clipboard

Creates an unsigned byte array of the specified size, filled with random bytes.

Since Kotlin 1.3

Fills the specified unsigned byte array with random bytes and returns it.

Since Kotlin 1.3
fun Random.nextUBytes(array: UByteArray, fromIndex: Int = 0, toIndex: Int = array.size): UByteArray

Fills a subrange of the specified UByte array starting from fromIndex inclusive and ending toIndex exclusive with random UBytes.

Since Kotlin 1.3
Link copied to clipboard
fun Random(seed: Int): Random

Returns a repeatable random number generator seeded with the given seed Int value.

Since Kotlin 1.3
fun Random(seed: Long): Random

Returns a repeatable random number generator seeded with the given seed Long value.

Since Kotlin 1.3