ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:ternary

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
new:ternary [2018/02/18 18:30] korshunnew:ternary [2018/02/18 18:31] (current) korshun
Line 8: Line 8:
  
 The only difference is that all arguments are evaluated before the function is called. This means that ''cond(x, f(), g())'' will call both ''f()'' and ''g()'', while ''x ? f() : g()'' will call only one of them. The only difference is that all arguments are evaluated before the function is called. This means that ''cond(x, f(), g())'' will call both ''f()'' and ''g()'', while ''x ? f() : g()'' will call only one of them.
 +
 +===== Examples =====
 +Without ''cond()'':
 +<code>
 +int color = CR_RED;
 +if (PlayerTeam() == TEAM_BLUE)
 +    color = CR_BLUE;
 +DrawSomething(color);
 +</code>
 +
 +With ''cond()'':
 +<code>
 +DrawSomething(cond(PlayerTeam() == TEAM_BLUE, CR_BLUE, CR_RED));
 +</code>
new/ternary.txt · Last modified: 2018/02/18 18:31 by korshun