Exceptions: Difference between revisions
Content added Content deleted
(Added Dyalect) |
|||
Line 858: | Line 858: | ||
<lang dyalect>func Integer.Add(x) { |
<lang dyalect>func Integer.Add(x) { |
||
throw |
throw @NegativesNotAllowed(x) when x < 0 |
||
this + x |
this + x |
||
} |
} |
||
try { |
try { |
||
12.Add(-5) |
12.Add(-5) |
||
} catch { |
} catch { |
||
NegativesNotAllowed(x) => print("Negative number: \(x)") |
@NegativesNotAllowed(x) => print("Negative number: \(x)") |
||
}</lang> |
}</lang> |
||
=={{header|DWScript}}== |
=={{header|DWScript}}== |