Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: empty 'else' block

by dws (Chancellor)
on Nov 20, 2004 at 16:11 UTC ( [id://409263]=note: print w/replies, xml ) Need Help??


in reply to empty 'else' block

Among the decent answers above, FoxtrotUniform makes a point that's worth expanding on a bit.

Someday in the future, someone (perhaps you) might pick up the code to extend it, and wonder at the logic. The conditional logic you've shown is simple, but conditional logic can get awkward. Leaving an empty else (or elsif) block is a way to signal to the future reader that you've considered that branch of the logic tree, and that there's nothing to do. If the logic is painfully simple, leaving a blank note isn't necessary, an intrudes on readability. But if the logic is messy, adding a short explanatory comment to the empty can save some future reader a lot of puzzling and pondering. It's a matter of finding the right balance.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://409263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found