flatMap

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

Applies transform to the encapsulated value if success, returning the KotlinResult produced by transform.

Failures pass through with the original Throwable unchanged.

Exceptions from transform are NOT caught — they propagate directly. Embed a result or resultOf block inside transform if you need exception catching, or use andThen / andThenOf instead.

Parameters

In

The encapsulated success input type.

Out

The success value type of the KotlinResult returned by transform.

See also