You're viewing a single thread.
View all comments
32
comments
If you're in a language that supports it, please don't use
if (false)
useif ($disallowAllUsers = false && $whateverTheRealConditionIs)
11 2 ReplyNever seen this, what language or buildsystem is this?
6 0 ReplyThat specific language is PHP, but the tip is applicable in any language that supports inline assignment.
3 0 Replyif (true === $wantToCauseErrorsForFun) { badOldFunction(); }
6 0 Reply
The assignment syntax is too close to comparison, which is what is more typical in that position. I would recommend
const bool _isFeatureEnabled = false; if (_isFeatureEnabled && ...)
if not a proper feature flag (or just remove the code).
1 0 ReplyIt seems much worse to use a setter in an if statement.
1 2 ReplyThink of it as inline attribution/documentation.
1 1 Reply
You've viewed 32 comments.
Scroll to top