unwrapOrElse abstract method

T unwrapOrElse(
  1. T fallback(
    1. E error
    )
)

Returns the successful value, or computes one from the error.

final count = const Err<int, String>('invalid')
    .unwrapOrElse((error) => error.length);
final existing = const Ok<int, String>(7)
    .unwrapOrElse((error) => error.length);

Implementation

T unwrapOrElse(T Function(E error) fallback);