Page 1 of 1

Simple Boolean question

Posted: Tue Aug 03, 2004 1:01 pm
by pickle
Hi All,

I was wondering if there's a simpler way to write this line:

Code: Select all

$row_bool = !$row_bool
I know it's pretty simple as it is, but I just can't stop thinking that there's a simpler way. Obfuscation is no object!!

Posted: Wed Aug 25, 2004 6:47 am
by Lord Sauron
???,

This must be about the shortest and most unclear question ever :?

Posted: Wed Aug 25, 2004 9:41 am
by pickle
I want to use fewer characters to do the same thing as:

Code: Select all

$row_bool = !$row_bool

Posted: Wed Aug 25, 2004 10:30 am
by feyd
I don't think there is a fewer characters way.. really.. other than shortening the variable name. :?

Posted: Wed Aug 25, 2004 10:35 am
by anjanesh
LOL

Posted: Wed Aug 25, 2004 11:55 am
by pickle
Ok, I was just wondering. It was just nagging at me that it was more complicated than it needed to be. Ah well, thanks for putting my mind to rest :)

Posted: Wed Aug 25, 2004 4:48 pm
by John Cartwright
i dont see how thats complicated at all..

Posted: Wed Aug 25, 2004 7:24 pm
by Illusionist
how is it more complicated than it should be? what do you think it should be? Or how could it be easier? I think

Code: Select all

$bool != $bool
Is pretty easy if you know that ! means not

Posted: Wed Aug 25, 2004 7:28 pm
by feyd
problem is.. that's always false. :D

Posted: Wed Aug 25, 2004 8:53 pm
by Illusionist
just as

Code: Select all

$bool = !$bool
would also always be false...

Posted: Wed Aug 25, 2004 9:16 pm
by feyd
actually, no.. your's doesn't set.. only checks.. pickles sets to the negation.

Posted: Wed Aug 25, 2004 10:00 pm
by Illusionist
ahh yes, i forgot, I was thinking of something different! haha my bad! :P

Posted: Thu Aug 26, 2004 9:15 am
by pickle
Well, you know how

Code: Select all

$var = $var + 1; /*can be written*/ $var++;
I was just thinking maybe there was a simple shortcut like

Code: Select all

$var=!
or something.

The question was meant more as a curious pipe dream than a problem I was dealing with. Thanks anyway folks.