Skip to main content
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@v.2.0.0-alpha.11/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

Example 1

import * as O from "./option.ts";

const toNumber = O.getOrElse(() => 0);

const result1 = toNumber(O.some(1)); // 1
const result2 = toNumber(O.none); // 0

Parameters

onNone: () => B