====== cond ====== {{tag>math acs_enhancements}} ''any cond(bool condition, any a, any b)'' [[:types|any - any type (int, fixed or str)]] ===== Description ===== If condition is true, returns a. Otherwise, returns b. It simulates the ''?:'' operator from C. Both a and b are evaluated. Do not do this: int y = cond(x, DoSomething(), DoSomethingElse()) as both ''DoSomething()'' and ''DoSomethingElse()'' will be called. If you are using [[:BCC]] or [[:GDCC]], it is recommended to use the real ''?:'' operator instead, which is not subject to this problem. ===== Examples ===== cond(true, A, B) -> A cond(false, A, B) -> B Without cond(): int color = CR_RED; if (PlayerTeam() == TEAM_BLUE) color = CR_BLUE; DrawSomething(color); With cond(): DrawSomething(cond(PlayerTeam() == TEAM_BLUE, CR_BLUE, CR_RED));