Note: None of this capability is currently implemented.
In our earlier discussion about exception handling, we introduced the idea that some functions can choose to throw an exception value on failure and a regular value on success. This is actually just a Result value being returned. Built-in language syntax just makes it clearer and simpler to work with such values:
- A function whose return signature is i32 throws Bool is another way to write a Result type: Result<i32, Bool>
- return 3 is equivalent to return ok.
- throw false is equivalent to return err[false].
The ? operator (try) and || operator (or else) offer more concise and readable ways to perform various common patterns for applying pattern matching blocks against a Result value.