firstOrNull

fun <T> Array<out T>.firstOrNull(): T?(source)

Returns the first element, or null if the array is empty.

Since Kotlin

1.0

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

Returns the first element matching the given predicate, or null if element was not found.

Since Kotlin

1.0

Returns the first element, or null if the collection is empty.

Since Kotlin

1.0

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

Returns the first element, or null if the list is empty.

Since Kotlin

1.0

Returns the first element, or null if the array is empty.

Since Kotlin

1.3

Returns the first element matching the given predicate, or null if element was not found.

Since Kotlin

1.3