Unwraps an Option type and returns the contained value if it exists. If the Option is "none", it returns the provided fallback value.
The type of the value.
The Option to unwrap.
The fallback value to return if opt is "none".
opt
The unwrapped value if present, or the fallback.
const name = unwrapOr(Some("Bob"), "Anonymous"); // "Bob"const name2 = unwrapOr(None(), "Anonymous"); // "Anonymous" Copy
const name = unwrapOr(Some("Bob"), "Anonymous"); // "Bob"const name2 = unwrapOr(None(), "Anonymous"); // "Anonymous"
Unwraps an Option type and returns the contained value if it exists. If the Option is "none", it returns the provided fallback value.