This one is probably easy. We know that the operator &+
does modular arithmetic on integers (wraps around), while the operator +
causes an error.
$ swift
1> var x: Int8 = 100
x: Int8 = 100
2> x &+ x
$R0: Int8 = -56
3> x + x
Execution interrupted. Enter Swift code to recover and continue.
What kind of error is this? I can't catch it and I can't turn it in to an optional:
4> do {try x + x} catch {print("got it")}
Execution interrupted. Enter Swift code to recover and continue.
5> try? x + x
Execution interrupted. Enter Swift code to recover and continue.
I'm pretty sure this kind of error is the same kind of error from this StackOverflow question (a divide-by-zero) but I don't know if this kind of error can be trapped. What simple thing am I missing? Can it be trapped or not? If so, how?