Conditional expressions

  • Updated

irScript supports a succinct, C#-style conditional expression syntax of the form:

sub-expression1 ? sub-expression2 : sub-expression3

var x = 55.4;

var result = x > 0 ? 'All signs point to yes' : 'No way';

The first sub-expression must resolve to a boolean value; if the result is true, the value of the conditional expression is the second sub-expression, and if false, the value of the conditional expression is the third sub-expression. The values returned from sub-expressions 2 and 3 must be of the same type.

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.