Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/fun/mod.ts>option.getOrElse

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function option.getOrElse
import { option } from "https://deno.land/x/fun@v2.0.0-alpha.6/mod.ts";
const { getOrElse } = option;

getOrElse operates like a simplified fold. One supplies a thunk that returns a default inner value of the Option for the cases where the option is None.

Examples

const toNumber = getOrElse(() => 0); const a = toNumber(some(1)); // 1 const b = toNumber(none); // 0

Parameters

onNone: () => B