The ternary conditional operator is a shorthand way of expressing if-else logic. It is often used in situations where a simple if-else statement would suffice, but where using the ternary operator can make the code more concise and easier to read.
String message = isLoggedIn ? 'Hello again' : 'Please sign up';
The basic syntax for using the ternary conditional operator is as follows:
condition ? expr1 : expr2
If the condition is true, then expr1 is evaluated and the value is returned. If the condition is false, then expr2 is evaluated and the value is returned.