3 ms·
That strikes me as a premature optimization. If you have a single condition, and unless makes it more readable, use unless. If the conditions do pile up in the
by WillPostForFood 4y ago
That strikes me as a premature optimization. If you have a single condition, and unless makes it more readable, use unless. If the conditions do pile up in the future, change it to an if.
- quest88 4y agoGreat, now you've got this weird logic on your style guide that your code reviewers will have to point to, and hopefully the new engineers on your team will remember. But maybe they're in a hurry and will quickly add another expression just this one time, multiplied by many engineers. It's far simpler to ban use of unless.
- WillPostForFood 4y agoIt is neither weird, nor complex. Use unless in cases where the if has a single, negative condition.