This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| new:ternary [2018/02/18 16:28] – created korshun | new:ternary [2018/02/18 16:31] (current) – korshun | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Ternary operator in ACS ====== | ====== Ternary operator in ACS ====== | ||
| - | [[ACC]] doesn' | + | [[ACC]] doesn' |
| - | To emulate it in ACC, ACSUtils implements the following trivial function: | + | '' |
| - | '' | + | If '' |
| - | + | ||
| - | If '' | + | |
| The only difference is that all arguments are evaluated before the function is called. This means that '' | The only difference is that all arguments are evaluated before the function is called. This means that '' | ||
| + | |||
| + | ===== Examples ===== | ||
| + | Without '' | ||
| + | < | ||
| + | int color = CR_RED; | ||
| + | if (PlayerTeam() == TEAM_BLUE) | ||
| + | color = CR_BLUE; | ||
| + | DrawSomething(color); | ||
| + | </ | ||
| + | |||
| + | With '' | ||
| + | < | ||
| + | DrawSomething(cond(PlayerTeam() == TEAM_BLUE, CR_BLUE, CR_RED)); | ||
| + | </ | ||