9/7/26Less than 1 minuteAbout 88 words
Concept: Ternary
A ternary operator is a conditional expression that evaluates to one of two values based on a condition. It is often used as a shorthand for simple if-else statements.
A ternary expression should only be used if each branch returns a value. While this isn't a hard rule, i.e. the code doesn't crash if you break it, it is still an important stylistic/semantic rule.
result = value_if_true if condition else value_if_false