method Result.prototype.unwrapOr
Result.prototype.unwrapOr<U>(defaultValue: U): T | U

Returns the Ok value or a default value if Err.

Examples

Example 1

const value = result.unwrapOr(0);
console.log(value); // 42 or 0

Type Parameters

The type of the default value

Parameters

defaultValue: U

The value to return if this result is Err

Return Type

T | U

The Ok value or the default value

Usage

import { Result } from "result/mod.ts";