Interface Result.Binder<E>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The unwrapping handle passed to
Result.binding(Function).
Calling on(Result) inside a binding block either returns the success
value or aborts the whole block at the first Result.Err encountered.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidAssert a condition with no value to bind: a guard, a permission check, an invariant.<T> TUnwrap aResultinside abindingblock: returns the value ifResult.Ok, otherwise short-circuits the enclosing block, which then evaluates to thatResult.Err.default <T> T
-
Method Details
-
on
Unwrap aResultinside abindingblock: returns the value ifResult.Ok, otherwise short-circuits the enclosing block, which then evaluates to thatResult.Err. Only legal while the surroundingbindingcall is on the stack. -
on
Bind anOptionalinside abindingblock: a present value is returned, an emptyOptionalshort-circuits the block withifEmpty.get(). LetsOptional- andResult-returning calls be sequenced together without bridging each one by hand.var candidates = bind.on(NonEmptyList.fromList(xs), AppError.NoCandidates::new); -
ensure
-