unwrapOr method

T unwrapOr(
  1. T defaultValue
)

Returns the success value if this is Ok, otherwise returns defaultValue.

Result.err('bad').unwrapOr(42); // 42

Implementation

T unwrapOr(T defaultValue) => isOk ? (this as Ok<T, E>).value : defaultValue;