re: What’s an unpopular software opinion you have? VIEW POST

FULL DISCUSSION
 

There is no justification in using Yoda Conditions in PHP or JavaScript.

In those languages, you should always use the === operator anyway, so if you can train yourself to always use ===, then you don’t need a hard to read safeguard against writing = instead of == in an if statement. And if you can’t train yourself to always use ===, but you can train yourself to write Yoda Conditions, then you’re weird.

Also, Yoda Conditions for any other operator (!==, <, >) are evil.

 

I'd expand that to a lot of other languages; even C based. Any compiler worth its salt can warn on "assignment in a boolean context" these days.

code of conduct - report abuse