!! operator
What's mean the "!!" operator?
|
Re: !! operator
It's not a single operator, but negation operator "!" being done twice. You would want to use that when you want to coerce a cell into a boolean, following the rule that 0 = false, anything else = true.
Code:
!!(0) == false |
Re: !! operator
So it will return always 0 or 1?
Thanks you! ;p |
Re: !! operator
You can also do "!= 0" to cast integer to bool.
|
Re: !! operator
PHP Code:
PHP Code:
It just mean the opposite. Am I right? |
Re: !! operator
PHP Code:
|
Re: !! operator
Quote:
|
Re: !! operator
Well, before I readed that post I tested if it works and got what you said. It was just an example for explain what I understood. Guess it works only with intergers and booleans.
|
Re: !! operator
Quote:
|
Re: !! operator
Using this on a boolean makes absolutely no sense since it's a double negative and will always return the original value. It's only relevant if you are trying to convert a non-boolean to a boolean value.
|
All times are GMT -4. The time now is 03:17. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.