|
|
|
|
|
by benaiah
4839 days ago
|
|
He explicitly mentions that short ternary expressions like this are fine. My rule of thumb is that if it fits comfortably on one line, it's fine to use the ternary. (Of course, my real rule of thumb is to use CoffeeScript in the first place, but that's not always an option.) |
|
In terms of lines of code—an imperfect metric but a useful one—his rewritten example is twice as long. That may seem like a small price to pay for an easier-to-understand snippet in isolation but if you start thinking about a complex system as a whole, and consider how complexity compounds as programs grow, that intuition changes considerably.
(I'm done being patronizing now.)