Exceptions: Difference between revisions
Content added Content deleted
m ("moved" SHORTENED CATCH to under the Langur language.) |
Langurmonkey (talk | contribs) |
||
Line 1,555: | Line 1,555: | ||
A catch can be shortened by using a single expression that does not start with a variable name. This uses the implicit .err exception variable. |
A catch can be shortened by using a single expression that does not start with a variable name. This uses the implicit .err exception variable. |
||
A shortened catch does not allow an else section. |
A shortened catch does not allow an else section (action for no exception). |
||
<lang Langur>catch if .err["cat"] == "math" { |
<lang Langur>catch if .err["cat"] == "math" { |
||
Line 1,563: | Line 1,563: | ||
}</lang> |
}</lang> |
||
<lang Langur>val . |
<lang Langur>val .safediv = f { .x / .y ; catch 0 } |
||
. |
.safediv(7, 7) # 1 |
||
. |
.safediv(7, 0) # 0</lang> |
||
=={{header|Lasso}}== |
=={{header|Lasso}}== |