ambivalence icon indicating copy to clipboard operation
ambivalence copied to clipboard

New API suggestion: ifLeft, ifRight

Open soerenBoisen opened this issue 4 years ago • 0 comments

Optional has method ifPresent to consume the value, if it is present. It would be useful to have the equivalent methods ifLeft and ifRight on Either.

Right now I'm doing this, which is laborious:

either.left().toOptional().ifPresent(left -> doStuff(left));

Instead I would like to do:

either.ifLeft(left -> doStuff(left));

soerenBoisen avatar Jun 16 '20 08:06 soerenBoisen