Multiple returns: Which one sets the final return value?

Yes, the language spec defines that “2” is the result. If a VM does it differently, it’s not spec-compliant.

Most compilers will complain about it. Eclipse, for example, will claim that the return block will never be executed, but it’s wrong.

It’s shockingly bad practice to write code like that, don’t ever do it 🙂

Leave a Comment