hairinmybellybutt@lemmy.world to Programmer Humor@lemmy.mlEnglish · 11 months agoadvancedlemmy.worldimagemessage-square32fedilinkarrow-up1428arrow-down115
arrow-up1413arrow-down1imageadvancedlemmy.worldhairinmybellybutt@lemmy.world to Programmer Humor@lemmy.mlEnglish · 11 months agomessage-square32fedilink
minus-squarexmunk@sh.itjust.workslinkfedilinkarrow-up11arrow-down2·11 months agoIf you’re in a language that supports it, please don’t use if (false) use if ($disallowAllUsers = false && $whateverTheRealConditionIs)
minus-squarePlexSheep@feddit.delinkfedilinkarrow-up6·11 months agoNever seen this, what language or buildsystem is this?
minus-squarexmunk@sh.itjust.workslinkfedilinkarrow-up3·edit-211 months agoThat specific language is PHP, but the tip is applicable in any language that supports inline assignment.
minus-squareThe Octonaut@mander.xyzlinkfedilinkarrow-up6·11 months agoif (true === $wantToCauseErrorsForFun) { badOldFunction(); }
minus-squareKogasa@programming.devlinkfedilinkarrow-up1·11 months agoThe 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).
minus-squareSpaceNoodle@lemmy.worldlinkfedilinkarrow-up1arrow-down2·11 months agoIt seems much worse to use a setter in an if statement.
minus-squarexmunk@sh.itjust.workslinkfedilinkarrow-up1arrow-down1·11 months agoThink of it as inline attribution/documentation.
If you’re in a language that supports it, please don’t use
if (false)
useif ($disallowAllUsers = false && $whateverTheRealConditionIs)
Never seen this, what language or buildsystem is this?
That specific language is PHP, but the tip is applicable in any language that supports inline assignment.
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).
It seems much worse to use a setter in an if statement.
Think of it as inline attribution/documentation.