(2021-04-30, 06:11 PM)kemper Wrote:
(2021-04-28, 07:58 AM)Shadow Wrote:
Good tutorial, you just forgot to mention that ternary operator supports multiple conditions.
For example:
PHP Code:
[/font][/size][/color]
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]SendClientMessage(playerid, -1, playerData[playerid][pAdmin] == 1 ? "Admin lvl 1" : playerData[playerid][pAdmin] == 2 ? "Admin lvl 2" : playerData[playerid][pAdmin] == 3 ? "Admin lvl 3" : "Admin lvl 4");[/font][/size][/color]
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]
And btw, you don't need brackets, just own preference.
In your example the readability of the code is suffering. Nesting of conditions is not a good idea.
I know, and I completely agree with you. Although the readability in ternary operator is a mess, this is a tutorial about it, and this should be mentioned.?
I remember when I was learning how ternary operator works in PAWN, I almost didn't find that example... I used to think that ternary operator accepts only one condition with two results...