|
|
|
|
|
by marginalia_nu
1279 days ago
|
|
As a random tangent, this is an "exception pattern" (Java). int foo() {
int i;
for (i = 0; i < 10; i++) {
try {
throw new RuntimeException();
}
finally {
if (i < 5) {
continue;
}
else {
break;
}
}
}
return i;
}
Compiles. Runs. Returns 5. |
|
From the language spec [0]:
If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and the throw of value V is discarded and forgotten).
[0] https://docs.oracle.com/javase/specs/jls/se8/html/jls-14.htm...