fold<R> method

R fold<R>(
  1. R onFailure(
    1. UseCaseException exception
    ),
  2. R onSuccess(
    1. T value
    )
)

Folds both branches into a single value.

Implementation

R fold<R>(
  R Function(UseCaseException exception) onFailure,
  R Function(T value) onSuccess,
) =>
    switch (this) {
      UseCaseSuccess(:final value) => onSuccess(value),
      UseCaseFailure(:final value) => onFailure(value),
    };