The second form has a clause which you cannot ever reach, so it is utterly useless. It is not "should never reach this" but "cannot ever reach this", so it might lead the unwary to think that you can somehow --by error-- get to this statement which is simply impossible.
The first form makes it abundantly clear that there are two mutually exclusive possibilities which are chosen on the boolean value of the condition.
This is the same with the third form but only because the first branch ends with a return, so one would have to analyse the content of the branch to note that the last part of the sub can only be reached if the condition is false and not because you can fall through the if part of the sub, which is what one would normally expect. One could say there is some action at a distance which prevents you from normally reaching the last part of the sub.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
In reply to Re: if else and not reachable coding style
by CountZero
in thread if else and not reachable coding style
by szabgab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |