W3cubDocs

/Kotlin

lastOrNull

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.

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.

fun <T> Iterable<T>.lastOrNull(): T?

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

fun <T> List<T>.lastOrNull(): T?

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

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