Welcome to the Monastery | |
PerlMonks |
Re: else after a return, exit, croak, dieby GrandFather (Saint) |
on Jan 25, 2023 at 02:05 UTC ( [id://11149856]=note: print w/replies, xml ) | Need Help?? |
I presume he was reacting to:
That can be rewritten as:
which reduces the number of lines of code and makes the logic clearer. Even better would be:
which avoids nested code paths altogether. Wherever the code path can't continue out of a previous block there is no need for an else. That avoids nesting following code and generally makes the logic easier to follow.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
In Section
Seekers of Perl Wisdom
|
|