randomOrNull

Common
JVM
JS
Native
1.3
@ExperimentalStdlibApi fun <T> Array<out T>.randomOrNull(): T?
@ExperimentalStdlibApi fun ByteArray.randomOrNull(): Byte?
@ExperimentalStdlibApi fun ShortArray.randomOrNull(): Short?
@ExperimentalStdlibApi fun IntArray.randomOrNull(): Int?
@ExperimentalStdlibApi fun LongArray.randomOrNull(): Long?
@ExperimentalStdlibApi fun FloatArray.randomOrNull(): Float?
@ExperimentalStdlibApi fun DoubleArray.randomOrNull(): Double?
@ExperimentalStdlibApi fun BooleanArray.randomOrNull(): Boolean?
@ExperimentalStdlibApi fun CharArray.randomOrNull(): Char?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun UIntArray.randomOrNull(): UInt?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun ULongArray.randomOrNull(): ULong?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun UByteArray.randomOrNull(): UByte?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun UShortArray.randomOrNull(): UShort?

Returns a random element from this array, or null if this array is empty.

Common
JVM
JS
Native
1.3
@ExperimentalStdlibApi fun <T> Array<out T>.randomOrNull(
    random: Random
): T?
@ExperimentalStdlibApi fun ByteArray.randomOrNull(
    random: Random
): Byte?
@ExperimentalStdlibApi fun ShortArray.randomOrNull(
    random: Random
): Short?
@ExperimentalStdlibApi fun IntArray.randomOrNull(
    random: Random
): Int?
@ExperimentalStdlibApi fun LongArray.randomOrNull(
    random: Random
): Long?
@ExperimentalStdlibApi fun FloatArray.randomOrNull(
    random: Random
): Float?
@ExperimentalStdlibApi fun DoubleArray.randomOrNull(
    random: Random
): Double?
@ExperimentalStdlibApi fun BooleanArray.randomOrNull(
    random: Random
): Boolean?
@ExperimentalStdlibApi fun CharArray.randomOrNull(
    random: Random
): Char?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun UIntArray.randomOrNull(
    random: Random
): UInt?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun ULongArray.randomOrNull(
    random: Random
): ULong?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun UByteArray.randomOrNull(
    random: Random
): UByte?
@ExperimentalStdlibApi @ExperimentalUnsignedTypes fun UShortArray.randomOrNull(
    random: Random
): UShort?

Returns a random element from this array using the specified source of randomness, or null if this array is empty.

Common
JVM
JS
Native
1.3
@ExperimentalStdlibApi fun <T> Collection<T>.randomOrNull(): T?

Returns a random element from this collection, or null if this collection is empty.

Common
JVM
JS
Native
1.3
@ExperimentalStdlibApi fun <T> Collection<T>.randomOrNull(
    random: Random
): T?

Returns a random element from this collection using the specified source of randomness, or null if this collection is empty.