Skip to content

Feature Proposal: Add unwrapOrElse method to Result #657

@JesseGovindan

Description

@JesseGovindan

Introduce a new instance method on Result and ResultAsync

unwrapOrElse<U>(op: (err: E) => U): T | U
  • Success (Ok): returns the contained T.
  • Failure (Err): calls the provided callback op with the error E and returns the callback’s return value.

This would prevent having to use .match with a callback such as (value) => value, in the first parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions