lastOrNull

Platform and version requirements: JVM (1.0), JS (1.0), 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?
@ExperimentalUnsignedTypes fun UIntArray.lastOrNull(): UInt?
@ExperimentalUnsignedTypes fun ULongArray.lastOrNull(): ULong?
@ExperimentalUnsignedTypes fun UByteArray.lastOrNull(): UByte?
@ExperimentalUnsignedTypes fun UShortArray.lastOrNull(): UShort?

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

Platform and version requirements: JVM (1.0), JS (1.0), 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?
@ExperimentalUnsignedTypes inline fun UIntArray.lastOrNull(
    predicate: (UInt) -> Boolean
): UInt?
@ExperimentalUnsignedTypes inline fun ULongArray.lastOrNull(
    predicate: (ULong) -> Boolean
): ULong?
@ExperimentalUnsignedTypes inline fun UByteArray.lastOrNull(
    predicate: (UByte) -> Boolean
): UByte?
@ExperimentalUnsignedTypes inline fun UShortArray.lastOrNull(
    predicate: (UShort) -> Boolean
): UShort?

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

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> Iterable<T>.lastOrNull(): T?

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

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
fun <T> List<T>.lastOrNull(): T?

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

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/last-or-null.html