Quote Originally Posted by Comintern View Post
I had actually never used the ternary operators before this assignment (and I agree with your assessment of how those lines are written). The prof had two requirements for the assignment -- design the program around the given prototypes and demonstrate using ? : syntax.
The ternary operator used as you used it is highly discouraged. If anything, it should be used in a simple, clear manner -- a simple left hand side of the ?, and simple true/false conditions on the right side of the ?.

Not only is it hard to decipher what you wrote, the ternary operator used multiple times on one line is a precedence nightmare. Things you think are being done in some order are not being done.

I don't understand why professors think it's worthwhile to have students write obfuscated code like this -- those code lines would never pass a real code review, as the reviewer themselves would need to look up, down, and sideways at those lines, and probably have to run the code to be convinced it really works.

Regards,

Paul McKenzie