singleOrNull

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)

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

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)

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

fun <T> Iterable<T>.singleOrNull(): T? (source)

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

fun <T> List<T>.singleOrNull(): T? (source)

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