DEV Community

Discussion on: What in the IF is a ternary?

Collapse
 
hugo__df profile image
Hugo Di Francesco

Since ternaries push you to use expressions, it makes your code less about control flow (if this, do that, else do something else) and more about "given this and that, send this value back".

It's very easy to write a lot of code in the if/else that should have been written as a set of functions acting one after the other to transform the data.

Of course if you've got small functions and aren't doing much within your if/else, it'll help long term maintainability.