defaultValue

If is Some, then returns its value. If is None, then returns the defaultValue.

Type

type defaultValue = <T>(value: T) => (option: Option<T>) => T

Examples

import {defaultValue, Some} from 'fnxt/option';

const getValue = defaultValue(0);
getValue(Some(42)) // -> 42
import {defaultValue, None} from 'fnxt/option';

const getValue = defaultValue(0);
getValue(None) // -> 0

See Also