Option and Null Safety
Cangjie provides multiple ways to handle Option values, making null-safe operations more convenient.
The ?? operator (coalescing operator) provides a default value when the value is None. The expression opt ?? default returns v when opt is Some(v), and returns default when opt is None. This allows safe unwrapping of Optional values.
The getOrThrow() method directly unwraps the value, returning v when the value is Some(v), and throwing an exception when it's None. This is suitable when you're certain the value must exist.
When the context clearly requires an Option<T> type, you can directly pass a T type value, and the compiler will automatically wrap it with Some. For example, a function returning an Int64 type value can directly return the number, which will be automatically wrapped as Some.
?? operator requires the default value on the right side to have the same type as the inner type of Option.Try modifying the findEmail function to distinguish between "username not found" and "user has no email" cases.