in reply to How Much Is Too Much (on one line of code)?

Like most people, I'm in the "too much" camp, but then I would think so, since I'm not sure I like ternaries at all.

I'll add the caveat though, that like most issues in communication this relies on an estimate of how the intended audience will read the code, and I can imagine situations where it might be better (or at least okay) to just use the one-liner.

For example, if you needed to do things like this relatively frequently in multiple templates, it would be irritating to have to look at the same block of 4 or 5 lines of code all over the place. If it didn't seem worth dedicating a special routine to the task, then just reusing this one line might seem cleaner.

  • Comment on Re: How Much Is Too Much (on one line of code)?