Created
July 7, 2016 13:00
-
-
Save afcastano/759ba1222e65cbd36d7c69754e8ad5fc to your computer and use it in GitHub Desktop.
flatMap method on the result monad.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public<U> Result<U> flatMap(Function<? super S, Result<U>> mapper) { | |
if (error.isPresent()) { | |
return fail(error.get()); | |
} | |
return mapper.apply(value.get()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment