fold<T> method
T
fold<T>(
- T onLeft(
- L left
- T onRight(
- R right
Folds the Either into a single value, applying onLeft if this is Left,
and onRight if this is Right.
Implementation
T fold<T>(
T Function(L left) onLeft,
T Function(R right) onRight,
) {
if (this is Left) {
return onLeft((this as Left<L, R>).value);
} else {
return onRight((this as Right<L, R>).value);
}
}