Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: in search of a more elegant if then else

by Anonymous Monk
on Feb 19, 2010 at 19:03 UTC ( [id://824231]=note: print w/replies, xml ) Need Help??


in reply to in search of a more elegant if then else

A more general question is: what are you computing with this if statement?

If it's something interesting and complex, think about whether or not you can factor out some or all the functionality into it's own function, so you can re-use it elsewhere, and test it independently.

If it's something simple, then the number of lines you need to code it won't really matter.

For example, it's probably better to use this for a complicated condition:

$score = skatingScore($technique, $interpretation, isRussian($judge) ) +;
but you can use something like this for a simple one...
$ranking = $isDisqualified ? "N/A" : rank($score);

--
AC

Log In?
Username:
Password:

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

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

    No recent polls found