Introduction
The ternary conditional operator lets you choose between two values quickly based on a condition. It makes your code shorter and easier to read when you have simple decisions.
When you want to assign a value based on a simple yes/no question.
When you want to print different messages depending on a condition.
When you want to return one of two values from a method quickly.
When you want to replace a short if-else statement with cleaner code.