Weird behavior of '?' operator..
So i tried using '?' operator in normal public functions ( previously i was using in formatex only )
DOESNT COMPILES ( error below from the return line to the '?' operator line ) Code:
error 029: invalid expression, assumed zeroPHP Code:
PHP Code:
Its a bug or something ? |
Re: Weird behavior of '?' operator..
Probably a bug compiler but usually you don't use "?" to set variables.
You can either use {} above, or enforcing line end with ";" or making check in a more conventional way "if ... else ...". |
Re: Weird behavior of '?' operator..
Quote:
So whats better in setting variables? if ... else... or '?' ? Thanks |
Re: Weird behavior of '?' operator..
First is probably more reliable.
|
Re: Weird behavior of '?' operator..
The Conditional Operator (?:) is generally used to return variables into left operand.
gi_PlayerMoney[player] = (gi_PlayerMoney[player] < 3000)? 0 : (gi_PlayerMoney[player]-3000); |
Re: Weird behavior of '?' operator..
(variable == 1) ? true : false
Warning with this, depends the check maybe return a false positive. (variable != 2) ? user_kill(id) ? set_user_health(id,100); and others. |
Re: Weird behavior of '?' operator..
Seems to be only used to assign a value, so as a function call parameter, or after a '=' sign.
|
| All times are GMT -4. The time now is 15:52. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.