sdk-common / com.tomtom.online.sdk.common.functional / Try / flatMap

flatMap

abstract fun <R : Any!> flatMap(@NonNull function: (in T) -> out Try<out R>!): Try<R>!

Maps success value to a new Try or passes a failure. In case of success function that is passed to this method will be called on the stored value, the resulting Try will be returned by the flatMap method. In case of failure flatMap will not invoke the passed function and just pass the failure again.

Parameters

function - (in T) -> out Try<out R>!: Function that is applied to the value stored in the success. This function returns a Try monad directly.

- Type of the resulting Try after flatMapping.

Return
Try<R>!: Success if the value was flatMapped, Failure otherwise.