it calls the 'when' function when the function check returns true for Right value
auto either = Either!(int, bool)(true); int message; auto result = either .when!alwaysTrue ({ return 2; }) .when((int value) { message = value; }); result.isLeft.should.equal(true); message.should.equal(2);
it calls the 'when' with the value function when the function check returns true for Right value
auto either = Either!(int, bool)(true); int message; auto result = either .when!alwaysTrue ((bool value) { return 2; }) .when((int value) { message = value; }); result.isLeft.should.equal(true); message.should.equal(2);
it does not call the 'when' function when the function check returns false for Right value
auto either = Either!(int, bool)(true); bool message; auto result = either .when!alwaysFalse ({ return 2; }) .when((bool value) { message = value; }); result.isRight.should.equal(true); message.should.equal(true);
it calls the 'when' function when the function check returns true for Left value
auto either = Either!(int, bool)(8); int message; auto result = either .when!alwaysTrueInt ({ return 2; }) .when((int value) { message = value; }); result.isLeft.should.equal(true); message.should.equal(2);
Match Left or Right values using a check function