Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: in search of a more elegant if then else

by aaron.m (Novice)
on Feb 19, 2010 at 00:17 UTC ( #824071=note: print w/replies, xml ) Need Help??


in reply to Re: in search of a more elegant if then else
in thread in search of a more elegant if then else

If it "fits," and is easy to read, use the ternary. Otherwise, use the if-then. Think in terms of which one will be easier to understand when someone else - ie. your boss - will be looking over your shoulder while you try to figure out a bug in something you wrote $x months or years ago.

Be kind to yourself.
  • Comment on Re^2: in search of a more elegant if then else

Replies are listed 'Best First'.
Re^3: in search of a more elegant if then else
by zebedee (Pilgrim) on Feb 19, 2010 at 09:07 UTC
    I go for the Friday 4 p.m. test. It's broken, it's 4 p.m. on Friday, you've had a LOOONGGG week, and you want to think about going home.

    Which one is going to be easier to read and fix?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2022-06-26 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (86 votes). Check out past polls.

    Notices?