reduceRightOrNull

Accumulates value starting with the last character and applying operation from right to left to each character and current accumulator value.

inline fun CharSequence.reduceRightOrNull(operation: (Char, acc: Char) -> Char): Char?(source)
val text = "Kotlin"

val firstUpperFromRight = text.reduceRightOrNull { ch, acc ->
    if (ch.isUpperCase()) ch else acc
}

println(firstUpperFromRight)   // Prints: K

Source