Possible Duplicate:
PHP - reversed order in if statement
Checking for null - what order?
Examining Zend Framework found that they do all the variable checkings reverse way:
public function setBootstrap($path, $class = null) {
if (null === $class) { // instead of if($class === null)
$class = 'Bootstrap';
}
What's the reason of doing this?
Is this also suitable for Java and C++ programming?
some people believe it helps them in avoiding to write a single =
(an assignment instead of a comparison for equality)
I believe that the advantage of doing so is much less than the loss of readability (and therefore maintainability!)
People who don't test their code may rely on this sort of trick. And to answer your question, yes, it is suitable for most languages who derive their syntax from C - I mean suitable, not recommended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With