@NonNull abstract fun <B : Any!> flatMap(@NonNull function: (in A) -> out Maybe<out B>!): Maybe<B>
Maps Just value or to a new Maybe or passes a Nothing. In case of a Just, function that is passed to this method will be called on the stored value, the resulting Maybe will be returned by the flatMap method. In case of Nothing flatMap will not invoke the passed function and just pass the Nothing again.
function
- (in A) -> out Maybe<out B>!: Function that is applied to the value stored in the Just. This function returns a Maybe monad directly.
- Type of the resulting Maybe after flatMapping
Return
Maybe<B>: Just
if the value was flatMapped, Nothing
otherwise.