in reply to if else and not reachable coding style

This might be a case for a postfix if. To quote TheDamian:

Reserve postfix if for flow-of-control statements.
PBP p94
sub sg { return 1 if COND; return 2; }

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re^2: if else and not reachable coding style
by shotgunefx (Parson) on Mar 08, 2006 at 13:40 UTC
    I'd probably go this path myself (or the third example).

    It really all depends on the conditions and the context the sub is used in.

    More often than not though, I don't have subroutines that can return several values where "undefined" isn't a possibility. Usually that being the case, a bare return at the end becomes the trap.

    -Lee
    "To be civilized is to deny one's nature."