Do you remember the value on the right side of an assignment operator is an r-value and the one on the left side is the l-value - quite obvious!
Flip the status quo to stay safe!
Sometimes, the conditional expressions are mistakenly/ unintentionally written as assignment expressions.
Quick Tip: Make sure the l-values lie on the right hand side of the conditional checks.
Flip the status quo to stay safe!
Sometimes, the conditional expressions are mistakenly/ unintentionally written as assignment expressions.
if(value = getValue() ) // a bug! - can cost you hours of debugging.
{
// I'm lucky to be executed almost always!
}
if(value = VALUE)
{
}
Quick Tip: Make sure the l-values lie on the right hand side of the conditional checks.
if(gettValue() = value) // error : cannot assign to r value
{
}
if(VALUE = value) // error : cannot assign to r value
{
}
No comments:
Post a Comment