Skip to main content
Module

x/optio/mod.ts>or

Minimum option type port of Rust
Latest
function or
import { or } from "https://deno.land/x/optio@1.0.0/mod.ts";

Returns the option if it contains a value, otherwise returns obtb.

Examples

Example 1

import { None, or, Some } from "https://deno.land/x/optio/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

const x = Some(2);
assertEquals(or(x, None), Some(2));

const y = None;
assertEquals(or(y, Some(100)), Some(100));

Parameters

option: Option<T>
obtb: Option<T>