Ternary operator

Readability is far more important than number of characters. I know that I have to read ternary conditionals at least twice before I can understand what is going on.

In the example above, when I read “if” I immediately know that I’m going to be evaluating a conditional. When the first character I see after the equal sign is another value I think assignment until I see the question mark and have to reread the line with a different context.

With the behavior of the if statement as it is, I can’t ever see myself favoring a shorter, harder read to read way to do the same thing.

3 Likes