aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators/CollectionExtensions.kt
blob: 0de4b5b112fd545acf14fdb4309810f24753221b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
package org.jetbrains.dokka.base.translators

// TODO [beresnev] remove this copy-paste and use the same method from stdlib instead after updating to 1.5
internal inline fun <T, R : Any> Iterable<T>.firstNotNullOfOrNull(transform: (T) -> R?): R? {
    for (element in this) {
        val result = transform(element)
        if (result != null) {
            return result
        }
    }
    return null
}