Yoda Conditions
The act of using
if (constant == variable)
instead of
if (variable == constant)
It’s like saying “If blue is the sky”.
Damn, that’s funny.
g this is funny for real, but there’s at least one situation where this bares a major pitfall:
if ( variable.equals( constant ) )
has the risk of an NPE, but yoda’s approach
if ( constant.equals( variable ) )
is quite safe.
g this is funny for real, but there’s at least one situation where this bares a major pitfall: if ( variable.equals(...
Is it wrong that I often use both orders in the very same if statement? eg. if (false === ($result = $obj->getResult()))...