ambivalence
ambivalence copied to clipboard
New API suggestion: ifLeft, ifRight
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));