result.valueOr

The value of a success, or a fallback on failure.

Value helperSince 0.3.0

Usage

TypeScript
Result.valueOr<T, F>(r: Result<T>, fallback: F): T | F

Parameters

  • rResult<T>

    The result to read.

    Required

  • fallbackF

    What to return when r failed.

    Required

Returns

The success value, or fallback unchanged; the diagnostics are dropped either way.

Use instead

Example

TypeScript
Result.valueOr(Result.fail('GEOMETRY_OP_FAILED', 'no hull'), []) // → []

See also