unwrap method

T unwrap()

Returns the success value, or throws a ResultException if this is Err.

Result.ok(42).unwrap();     // 42
Result.err('bad').unwrap(); // throws ResultException

Implementation

T unwrap() {
  if (isOk) return (this as Ok<T, E>).value;
  throw ResultException((this as Err<T, E>).error);
}