< pre class="lang-cc Prettyprint-override">
Код: Выделить всё
private void IfElse(int inVal)
{
float out = 1f;
if (inVal == 0) out = 0.5f;
return out;
}
Код: Выделить всё
private void DoMath(int inVal)
{
float out = (float)inVal;
out = 1f - (out * 0.5f);
return out;
}
Код: Выделить всё
int inValue = 0; // 0 or 1
float outValue = IfElse(inValue);
Код: Выделить всё
int inValue = 0; // 0 or 1
float outValue = DoMath(inValue);
Подробнее здесь: https://stackoverflow.com/questions/783 ... -or-ifelse
Мобильная версия