2024-04-19 16:56:29 -07:00
|
|
|
val .div = fn(.x, .y) {
|
2023-07-01 11:58:00 -04:00
|
|
|
[.x / .y, true]
|
|
|
|
|
catch {
|
2024-04-19 16:56:29 -07:00
|
|
|
if _err'msg -> re/division by 0/ {
|
2023-07-01 11:58:00 -04:00
|
|
|
[0, false]
|
|
|
|
|
} else {
|
|
|
|
|
# rethrow the error if not division by 0
|
|
|
|
|
throw
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writeln .div(3, 2)
|
|
|
|
|
writeln .div(3, 0)
|