Quote:
Originally Posted by Electrifying
What does two parentheses mean on a conditional? like
Код:
if(! (3 <= strlen( inputtext ) <= 20))
Код:
if( (pInfo[i][AdminLevel] > pInfo[playerid][AdminLevel] ) && (pInfo[i][AdminLevel] >= 2) && (i != playerid)
|
There is a specific order in which they are processed.
Very similar to this:
is not the same as
The same can be said about conditions. Some expressions are meant to be concatenated.
Код:
if(3 <= strlen( inputtext ) <= 20)
will check if strlen(inputtext) is greater than or equal to 3
and smaller than or equal to 20.
With the additional brackets and the exclamation mark, this will negate the outcome of this check. So this:
Код:
if(! (3 <= strlen( inputtext ) <= 20))
will check if strlen(inputtext) is NOT in the specified range.
Same for expressions where AND and OR are used at the same time, there is a specific order and when it's not respected the outcome will be totally different.
So this:
Код:
if(var1 == 3 && var2 == 4 || var == 4 && var2 == 3)
is very different from this:
Код:
if((var1 == 3 && var2 == 4) || (var == 4 && var2 == 3))
The first one will not accept any values, as the check will fail at the second AND.
The second code will accept 3 & 4 OR 4 & 3 respectively.