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

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