single

fun <T> Array<out T>.single(): T (source)
fun ByteArray.single(): Byte (source)
fun ShortArray.single(): Short (source)
fun IntArray.single(): Int (source)
fun LongArray.single(): Long (source)
fun FloatArray.single(): Float (source)
fun DoubleArray.single(): Double (source)
fun BooleanArray.single(): Boolean (source)
fun CharArray.single(): Char (source)

Returns the single element, or throws an exception if the array is empty or has more than one element.

inline fun <T> Array<out T>.single(
    predicate: (T) -> Boolean
): T
(source)
inline fun ByteArray.single(
    predicate: (Byte) -> Boolean
): Byte
(source)
inline fun ShortArray.single(
    predicate: (Short) -> Boolean
): Short
(source)
inline fun IntArray.single(predicate: (Int) -> Boolean): Int (source)
inline fun LongArray.single(
    predicate: (Long) -> Boolean
): Long
(source)
inline fun FloatArray.single(
    predicate: (Float) -> Boolean
): Float
(source)
inline fun DoubleArray.single(
    predicate: (Double) -> Boolean
): Double
(source)
inline fun BooleanArray.single(
    predicate: (Boolean) -> Boolean
): Boolean
(source)
inline fun CharArray.single(
    predicate: (Char) -> Boolean
): Char
(source)
inline fun <T> Iterable<T>.single(
    predicate: (T) -> Boolean
): T
(source)

Returns the single element matching the given predicate, or throws exception if there is no or more than one matching element.

fun <T> Iterable<T>.single(): T (source)

Returns the single element, or throws an exception if the collection is empty or has more than one element.

fun <T> List<T>.single(): T (source)

Returns the single element, or throws an exception if the list is empty or has more than one element.