In PHP, you might need "if (some_boolean === true)".
There is a fashion for inverting it: "if (true == some_boolean)", which seems arse-over-elbow to me (I do know why people do that).
There is a fashion for inverting it: "if (true == some_boolean)", which seems arse-over-elbow to me (I do know why people do that).
if (true = some_boolean)
While this will silently result in an assignment of true to the some_boolean variable, not intended the equality test if (some_boolean = true)
Editor hints and linting can help catch this as well, but those aren’t always available (or weren’t available in the past). I think I first saw this in Code Complete 2.Here’s some more explanation
https://softwareengineering.stackexchange.com/questions/7408...
Looks like the pattern is sometimes referred to as a Yoda expression.