Created
May 16, 2017 14:03
-
-
Save njlr/22e6d06d219628a583a12f372a849902 to your computer and use it in GitHub Desktop.
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
Either<string, int> myEither = left("hello"); // constructs a either containing a leftValue; | |
int count = myEither | |
.rightMap([](auto num) { return num + 1; }) // adds 1 if rightValue is present | |
.leftMap([](auto str) { return str + "world"; }) // appends "world" if leftValue is present | |
.leftMap([](auto str) { return str.size(); }) | |
.join(); // both sides have now the same type, lets join... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment