|
November 10, 1999 The Conditional Operator Tips: November 1999
Yehuda Shiran, Ph.D.
|
|
The conditional operator is unique because it is trinary (three operands) and because it returns values of all types. It can return a numeric value, a string, a Boolean value, and so on. The first operand is the condition. The condition must be an expression that evaluates to a Boolean value, either true or false. The second operator holds the value that the operator should return if the condition is true. The third operand is the value that the expression evaluates to if the condition is false. The conditional operator is often used with an assignment operator. For example:
The variable
People who read this tip also read these tips: Look for similar tips by subject: |