DEV Community

Discussion on: Why I'm phasing out ternary statements

Collapse
andrewharpin profile image
Andrew Harpin

I personally hate them, I personally find an if/else faster to determine the code flow than this behaviour.

The notification that this is a conditional occurs at the start of the line, whereas the ternary operator occurs roughly half way through the line, requiring you to read most of the line to understand the impact.

Minimising the number of lines of code is not effective in making code more readable. I'm a C programmer by trade, I could write the whole program on one line if I really wanted.

It's annoying and not beneficial.

How fast someone with zero familiarity of the code can pick up what is happening is the true measure of readability. Especially if that person is a non coder, good code will read like a document in the language it is written in.