Unwrap option, shortcut

Is there a concise way to obtain the “inner value” of an option without using switch? For example:

let str = Some("hi there!")
let unwrapStr = switch str { // a shorcut would be nice
| Some(value) => value
| None => ""
}

In other languages, like Rust, we can use the unwrap_or function ( let unwrapStr = str.unwrap_or("") ).

We’ve got let str = Belt.Option.getWithDefault(maybeStr, "")

4 Likes