You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Result<T> is the standard type for error handling. It represents either success (Ok) containing a value, or failure (Err) containing a string error message.
Usage
import "std/result.zc"
fn divide(a: int, b: int) -> Result<int> {
if (b == 0) {
return Result<int>::Err("Division by zero");
}
return Result<int>::Ok(a / b);
}
fn main() {
let res = divide(10, 2);
if (res.is_ok()) {
println "Result: {res.unwrap()}";
} else {
println "Error: {res.err}";
}
}