RosettaCodeData/Task/Exceptions/Dyalect/exceptions.dyalect
2023-07-01 13:44:08 -04:00

10 lines
178 B
Text

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