This is a similar question to Why doesn't Option have a fold method?, but for functional-java.
I want to perform some side-effect if an option is None. Is there something I can use other than if maybeT.isNone()
?
I'm thinking along the lines of Option<B> optionA.fold(Effect<Unit> none, F<A, B> some)
.
Is there something that already exists?
You could use the option method
public final <B> B option(final P1<B> b, final F<A, B> f) {
return isSome() ? f.f(some()) : b._1();
}