fun <T> Iterable<T>.singleOrNull(): T?
Returns single element, or null
if the collection is empty or has more than one element.
fun <T> List<T>.singleOrNull(): T?
Returns single element, or null
if the list is empty or has more than one element.
inline fun <T> Iterable<T>.singleOrNull( predicate: (T) -> Boolean ): T?
inline fun <T> Array<out T>.singleOrNull( predicate: (T) -> Boolean ): T?
inline fun ByteArray.singleOrNull( predicate: (Byte) -> Boolean ): Byte?
inline fun ShortArray.singleOrNull( predicate: (Short) -> Boolean ): Short?
inline fun IntArray.singleOrNull( predicate: (Int) -> Boolean ): Int?
inline fun LongArray.singleOrNull( predicate: (Long) -> Boolean ): Long?
inline fun FloatArray.singleOrNull( predicate: (Float) -> Boolean ): Float?
inline fun DoubleArray.singleOrNull( predicate: (Double) -> Boolean ): Double?
inline fun BooleanArray.singleOrNull( predicate: (Boolean) -> Boolean ): Boolean?
inline fun CharArray.singleOrNull( predicate: (Char) -> Boolean ): Char?
Returns the single element matching the given predicate, or null
if element was not found or more than one element was found.
fun <T> Array<out T>.singleOrNull(): T?
fun ByteArray.singleOrNull(): Byte?
fun ShortArray.singleOrNull(): Short?
fun IntArray.singleOrNull(): Int?
fun LongArray.singleOrNull(): Long?
fun FloatArray.singleOrNull(): Float?
fun DoubleArray.singleOrNull(): Double?
fun BooleanArray.singleOrNull(): Boolean?
fun CharArray.singleOrNull(): Char?
Returns single element, or null
if the array is empty or has more than one element.
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/single-or-null.html