go ahead... be a heretic | |
PerlMonks |
Re^5: Perl can do it, take 1 (sentence generation)by BrowserUk (Patriarch) |
on Jun 21, 2005 at 14:37 UTC ( [id://468695]=note: print w/replies, xml ) | Need Help?? |
That's quite clever, but that is what I would classify as a 'trick' on the basis that if else elsif are designed conditional invocation of blocks of code. The ternary is specifically designed for conditional assignment of values. Not many people baulk at using . The only problem here is that there are two conditions instead of one, requiring the use of chained ternaries. But then, noone baulks at using nested or chained ifs, and the structure of the code is identical. And is it really any clearer?
To my eyes, the former is not even slightly clearer than the latter, but then I use this construct freely, when applicable and so I am used to seeing it and it presents me with no problems to read it. Especially if it is formatted well. Indeed. The only reason why some of Perl's more obscure contructs are eshewed by some, is because they are obscure. It's a self-propogating argument. If more people used them, they would less obscure--more familiar--and the reason for not using them diminishes. I'd go even further and say that using the appropriate operators for the operation has further benefits:
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
In Section
Meditations
|
|