fold<B> abstract method

B fold<B>(
  1. B ok(
    1. O ok
    ),
  2. B err(
    1. E err
    )
)

Breaks the result into Ok or Err.

The values are exposed in the callback parameter.

Returns a single value from both of the callbacks.

Example:

final result = ok<String, Exception>('hi');

result.fold(
  (ok) => print(ok),
  (err) => print(err),
);

Implementation

B fold<B>(B Function(O ok) ok, B Function(E err) err);