Without wanting to be influenced by the other comments, my opinion is that it's too much, without braces or a comment to make it clear in what order things happen, or why they are happening.
Without the braces I probably have to .. no, I have to look up what the precedence order is, or try it in the debugger. Yes, certainly after developing in Perl for ten years I should probably know that, but I don't. Also, the assignment to $country followed immediately by a re-assignment to $country isn't a style I love.
OK, (after trying it in the debugger) it does do the ternary first and the if statement within that .. that's what I expected.
To answer your question, no, this code is not clear.
Was there a comment explaining the business logic? The left side of my brain suggests ..
.. but the right side of my brain prevails, and provides a much better comment:# Blank country field if Great Britain, otherwise upper # case country name within square brackets. Leave field # empty if country is undefined.
# Since we're mailing from GBR, only display the country # if it's not GBR, and leave a blank country field blank.
Above all, strive for clarity.
In reply to Re: How Much Is Too Much (on one line of code)?
by talexb
in thread How Much Is Too Much (on one line of code)?
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |