DEV Community

Cover image for Ternary Conditional Operators
Alexandre Bento Freire
Alexandre Bento Freire

Posted on

Ternary Conditional Operators

Python is one of the few popular modern languages that doesn't follow the traditional C-style syntax for ternary conditional operators. Instead of the standard format where the condition is followed by the true expression and then the false expression, Python places the true expression first, followed by the condition and the false expression.

However, not every language supports ternary conditional operators. For example, Go, a rapidly growing language in popularity, does not have a ternary operator. This absence reflects Go's design philosophy, which prefers simplicity and avoids operators that might reduce code readability.

The table below summarizes how different programming languages and language-like systems (such as SQL and Excel) handle ternary conditional operators or their equivalents.

Top comments (0)