flatMap

inline fun <In, Out> KotlinResult<In>.flatMap(onSuccess: (In) -> KotlinResult<Out>): KotlinResult<Out>

Like Result.map, applies the onSuccess function to the encapsulated value.

Note, that this function rethrows any Throwable exception thrown by onSuccess function. However, since this is flatMap, you can easily embed another resultOf inside the onSuccess function.