Ternary
Ternary Operator
The ternary operator or conditional operator, is a simplified method for performing a basic if-else
statement in a single line of code. The syntax typically follows the pattern: condition ? expression_if_true : expression_if_false
. This allows for more concise and readable code when you need to assign a value based on a condition.
Python Example
C# Example
Last updated
Was this helpful?