Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ahh/src/result/mod.ts>R.unwrapOr

Idiomatic type-safety structures for TypeScript.
Go to Latest
method R.unwrapOr
import { R } from "https://deno.land/x/ahh@v0.10.0/src/result/mod.ts";

Returns res if it is an Ok, or returns default_.

Examples

import { R } from "./mod.ts";

console.log(R.unwrapOr<number, Error>(1, 2)); // 1
console.log(R.unwrapOr(Error(), 2)); // 2

Type Parameters

T
E extends Error

Parameters

res: Result<T, E>
default_: T