by symbol-mason · 1y ago · 0 comments
Pattern matching, nullable types, and the Try* method conventions are also ways of representing the potential for failure explicitly.
A b() throws C
fn b() -> Result<A, C>
A a = try {
b()
} catch (C c) {
new A()
}
val a = b() match {
Ok(a) => a
Failure(c) => A()
}