OptionUnwrap<T> extension

Extraction with a fallback on Option.

An extension rather than members of Option, so the fallback's type comes from the static type at the call site. As members they were checked against the type a value was built with, and a None<int>() held in an Option<num> threw a TypeError for a double fallback.

on

Methods

unwrapOr(T fallback) → T

Available on Option<T>, provided by the OptionUnwrap extension

Returns the present value, or fallback when this option is absent.
unwrapOrElse(T fallback()) → T

Available on Option<T>, provided by the OptionUnwrap extension

Returns the present value, or computes one when this option is absent.