aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/util/listutil.kt
blob: 73cb23e44b963ce55883e21ed881ad83e821d045 (plain)
1
2
3
4
5
6
7
8
9
package moe.nea.firmament.util

fun <T, R> List<T>.lastNotNullOfOrNull(func: (T) -> R?): R? {
    for (i in indices.reversed()) {
        return func(this[i]) ?: continue
    }
    return null
}