two parentheses in a conditional -
Electrifying - 28.09.2018
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)
Re: two parents in a conditional -
NaS - 28.09.2018
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.
Re: two parents in a conditional -
Electrifying - 28.09.2018
Quote:
Originally Posted by NaS
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.
|
Thanks!!
Re: two parents in a conditional -
v1k1nG - 28.09.2018
Well thread title look cool anyways
Re: two parents in a conditional -
TheToretto - 28.09.2018
lmao I thought your parents were in conditional sentence
Re: two parents in a conditional -
Electrifying - 28.09.2018
Quote:
Originally Posted by TheToretto
lmao I thought your parents were in conditional sentence
|
hahaha I noticed, sorry I don't speak english