The content of result
if it is an Ok
, otherwise
defaultValue
.
Safely get the value out of the Ok
variant of a Result
.
This is the recommended way to get a value out of a Result
most of the time.
import { ok, err, unwrapOr } from 'true-myth/result';
const anOk = ok<number, string>(12);
console.log(unwrapOr(0, anOk)); // 12
const anErr = err<number, string>('nooooo');
console.log(unwrapOr(0, anErr)); // 0
The value to use if result
is an Err
.
The content of result
if it is an Ok
, otherwise
defaultValue
.
Safely get the value out of the
Ok
variant of aResult
.This is the recommended way to get a value out of a
Result
most of the time.