6 ms·
> In this case the surprise factor comes in, because we are used to equating finally block with cleanup and I concur that many would trip on this the first time
by Akronymus 11mo ago
> In this case the surprise factor comes in, because we are used to equating finally block with cleanup and I concur that many would trip on this the first time. But if you gave this exercise some time and asked "what should happen if finally block contains control flow statements?" the reasonable answer should be "take precedence", because the behavior would be surprising/cursed otherwise.
Wouldn't the reasonable behaviour be "throw a compiler error"?
- friendzis 11mo agoCan the compiler perform sufficiently deep static analysis to cover all possible cases? At least in Java it is by definition impossible.