EnglishРусский  
Share/Save/Bookmark
 

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Gentee needs your help!
How to advertise with us
 
laptop battery

The conditional operator ?

The conditional operator ? operates in the similar way as the if-else statement, but the conditional operator can be located in the expression. The operator is a ternary operator (it takes three operands). The operands separated by commas are enclosed in parentheses; the first logical (integer) expression is evaluated. If the value is nonzero (TRUE), the second expression will be evaluated, the value of which will be a result of the conditional operation. Otherwise, the third operand will be evaluated, the value of which will be returned.

r = ?( a == 10, a, a + b ) 
if a >= ?( x, 0xFFF, ?( y < 5 && y > 2, y, 2*b )) + 2345
{
   ...
}

Edit