RosettaCodeData/Task/Exceptions/Dyalect/exceptions.dyalect

11 lines
178 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
func Integer.Add(x) {
throw @NegativesNotAllowed(x) when x < 0
this + x
}
try {
12.Add(-5)
} catch {
@NegativesNotAllowed(x) => print("Negative number: \(x)")
}