Jump to content

Exceptions: Difference between revisions

m
Line 1,530:
</pre>
 
=={{header|Langurlangur}}==
Exceptions in langur are hashes guaranteed to contain certain fields, even if they're empty.
 
Line 1,537:
An else section on a catch is optional (available from version 0.5.0 and higher).
 
<lang Langurlangur># do something
throw "not a math exception"
 
Line 1,557:
A shortened catch does not allow an else section (action for no exception).
 
<lang Langurlangur>catch if .err["cat"] == "math" {
# change result
} else {
Line 1,563:
}</lang>
 
<lang Langurlangur>val .safediv = f { .x / .y ; catch 0 }
.safediv(7, 7) # 1
.safediv(7, 0) # 0</lang>
1,007

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.