singleOrNull

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

Returns single element, or null if the array is empty or has more than one element.

Common
JVM
JS
Native
1.0
inline fun <T> Array<out T>.singleOrNull(
    predicate: (T) -> Boolean
): T?

(source)
inline fun ByteArray.singleOrNull(
    predicate: (Byte) -> Boolean
): Byte?

(source)
inline fun ShortArray.singleOrNull(
    predicate: (Short) -> Boolean
): Short?

(source)
inline fun IntArray.singleOrNull(
    predicate: (Int) -> Boolean
): Int?

(source)
inline fun LongArray.singleOrNull(
    predicate: (Long) -> Boolean
): Long?

(source)
inline fun FloatArray.singleOrNull(
    predicate: (Float) -> Boolean
): Float?

(source)
inline fun DoubleArray.singleOrNull(
    predicate: (Double) -> Boolean
): Double?

(source)
inline fun BooleanArray.singleOrNull(
    predicate: (Boolean) -> Boolean
): Boolean?

(source)
inline fun CharArray.singleOrNull(
    predicate: (Char) -> Boolean
): Char?

(source)
inline fun <T> Iterable<T>.singleOrNull(
    predicate: (T) -> Boolean
): T?

(source)
@ExperimentalUnsignedTypes inline fun UIntArray.singleOrNull(
    predicate: (UInt) -> Boolean
): UInt?

(source)
@ExperimentalUnsignedTypes inline fun ULongArray.singleOrNull(
    predicate: (ULong) -> Boolean
): ULong?

(source)
@ExperimentalUnsignedTypes inline fun UByteArray.singleOrNull(
    predicate: (UByte) -> Boolean
): UByte?

(source)
@ExperimentalUnsignedTypes inline fun UShortArray.singleOrNull(
    predicate: (UShort) -> Boolean
): UShort?

(source)

Returns the single element matching the given predicate, or null if element was not found or more than one element was found.

Common
JVM
JS
Native
1.0
fun <T> Iterable<T>.singleOrNull(): T?
(source)

Returns single element, or null if the collection is empty or has more than one element.

Common
JVM
JS
Native
1.0
fun <T> List<T>.singleOrNull(): T?
(source)

Returns single element, or null if the list is empty or has more than one element.