Re: Alternate Colors in Rows ($r=!$r)
| From: | Jeff Cohan | Date: | Fri, 05 Oct 2007 20:40:29 +0000 |
| Subject: | Re: Alternate Colors in Rows ($r=!$r) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262847@lists.php.net to get a copy of this message | ||
Nathan Nobbe wrote:
> personally, i wont argue w/ the compact nature of the
> statement; its nice.
I agree. Very elegant. Thanks for the clarifications, folks.
> its mysterious statements like this that make code fragile,
> imho. i prefer the modulus approach.
I would have agreed before reading the clarification. Not so sure
now...
At the risk of semantic nitpicking, and only because I find this
discussion stimulating (pity us poor geeks), I might call "($r=!$r)"
esoteric rather than mysterious, even though I'm the one who asked
the question, suggesting it was a mystery to me.
Garsh: In the early days, I thought I had to write:
if ( strval($somevar) > 0 )
or
if ( $somevar ) === true )
and found:
if ( strval($somevar) )
and
if ( $somevar )
mysterious.
!
I suppose my point is that some things start out as mysterious
simply because they are a bit esoteric, further down in the manual.
But I agree with you, Nathan, in principle, about mysterious code
making things fragile. When I first got comfortable with the ternary
operator, I went crazy trying to write cool one-liner conditional
statements with it. Then, months (or even days) later, when I needed
to make changes to those one-liners, I had to scratch my head a lot
to figure out what was what. I've since decided that sometimes, in
the interest of de-mystifying my own code, there's nothing like a
good old IF loop.
My $0.02.