fold<R> abstract method

R fold<R>(
  1. R onSuccess(
    1. T value
    ), {
  2. required R onFailure(
    1. ErrorMessage errorMessage
    ),
})

Allows handling the success and failure cases of a Result separately and returns a value of type R.

onSuccess is the function that transforms the value if the result is a success. onFailure is the function that transforms the error message if the result is a failure.

Implementation

R fold<R>(
  R Function(T value) onSuccess, {
  required R Function(ErrorMessage errorMessage) onFailure,
});