lastOrNull

Common
JVM
JS
Native
1.0
fun <T> Array<out T>.lastOrNull(): T?
fun ByteArray.lastOrNull(): Byte?
fun ShortArray.lastOrNull(): Short?
fun IntArray.lastOrNull(): Int?
fun LongArray.lastOrNull(): Long?
fun FloatArray.lastOrNull(): Float?
fun DoubleArray.lastOrNull(): Double?
fun BooleanArray.lastOrNull(): Boolean?
fun CharArray.lastOrNull(): Char?

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

Common
JVM
JS
Native
1.0
inline fun <T> Array<out T>.lastOrNull(
    predicate: (T) -> Boolean
): T?
inline fun ByteArray.lastOrNull(
    predicate: (Byte) -> Boolean
): Byte?
inline fun ShortArray.lastOrNull(
    predicate: (Short) -> Boolean
): Short?
inline fun IntArray.lastOrNull(
    predicate: (Int) -> Boolean
): Int?
inline fun LongArray.lastOrNull(
    predicate: (Long) -> Boolean
): Long?
inline fun FloatArray.lastOrNull(
    predicate: (Float) -> Boolean
): Float?
inline fun DoubleArray.lastOrNull(
    predicate: (Double) -> Boolean
): Double?
inline fun BooleanArray.lastOrNull(
    predicate: (Boolean) -> Boolean
): Boolean?
inline fun CharArray.lastOrNull(
    predicate: (Char) -> Boolean
): Char?
inline fun <T> Iterable<T>.lastOrNull(
    predicate: (T) -> Boolean
): T?
inline fun <T> List<T>.lastOrNull(
    predicate: (T) -> Boolean
): T?

Returns the last element matching the given predicate, or null if no such element was found.

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

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

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

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