Last active
July 30, 2017 18:28
-
-
Save nachivpn/b2cd15fa5105898bbb33a0f007f4ca59 to your computer and use it in GitHub Desktop.
EitherPatternMatching
This file contains hidden or 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
//return a printable string containing component details, exception if component is unavailable | |
public String print(Either<Exception, Component> componentResp){ | |
return componentResp.match( | |
(Exception ex) -> "Failed because " + ex.getMessage(), | |
(Component p) -> "Component info: " + p.prettyResult()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment