Skip to main content

Conditional Operators

The conditional operator allows an ‘if then else’ type construct and follows the C# and Java convention.

The first part of the expression is the value being checked.

The second part is the value which will be returned if the first value evaluates to true.

The third value is returned if the first value evaluates to false.

SyntaxDescription
... ? ... : ...If – then – else
ExampleFor example, the following would return “Yes” because the first part, 1=1, evaluated to true:
1 == 1 ? "Yes" : "No"
ExampleAlternatively, this example would evaluate to “Nope”:
"Dog" == "Cat" ? "Yup" : "Nope"

Stuck on this step? Email support@eight-wire.com