Originally posted by Shriya Kishore: Y cant they just write simple if statements
The ternary operator can be very useful and terse when making a simple decision in an expression. It can also be confusing when used as shown in your example. A judicious mix of if statements and the ternary operator can be used to achieve code that is as brief as possible, while still being readable and clear.
A good dose of thoughtful code formatting can also go a long way to enhancing the clarity of the code.