IF
Description
The IF function is a conditional judgment function that returns expr1 or expr2 based on the provided conditional expression (cond). When the result of the conditional expression is true, the IF function returns the value of expr1; when the result of the conditional expression is false, it returns the value of expr2.
Parameter Description
- cond (conditional expression): An expression that returns a boolean value (true or false).
- expr1 (expression 1): When cond is true, the IF function returns the value of this expression.
- expr2 (expression 2): When cond is false, the IF function returns the value of this expression.
Return Result
The return type of the IF function is the same as the type of expr1 and expr2.
Example
- Example 1: Compare values and return results
- Example 4: Determine Grade Based on Score