fold<T> method

T fold<T>(
  1. T onLeft(
    1. L
    ),
  2. T onRight(
    1. R
    )
)

Folds this Either into a single value

Implementation

T fold<T>(T Function(L) onLeft, T Function(R) onRight) {
  return switch (this) {
    Left(:final value) => onLeft(value),
    Right(:final value) => onRight(value),
  };
}