Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision |
new:ternary [2018/02/18 18:28] – korshun | new:ternary [2018/02/18 18:30] – korshun |
---|
[[ACC]] doesn't support the ternary operator '?:', but [[BCC]] and [[GDCC]] do. To emulate it in ACC, ACSUtils implements the following trivial function: | [[ACC]] doesn't support the ternary operator '?:', but [[BCC]] and [[GDCC]] do. To emulate it in ACC, ACSUtils implements the following trivial function: |
| |
''any cond(bool condition, any whentrue, any whenfalse)'' | ''any cond(bool condition, any a, any b)'' |
| |
If ''condition'' is true, it returns ''whentrue'', otherwise it retuns ''whenfalse''. | If ''condition'' is true, it returns a, otherwise it returns b. |
| |
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. |