1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe> * * SPDX-License-Identifier: GPL-3.0-or-later */ 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 }