The use of NULL == condition
provides more useful behaviour in the case of a typo, when an assignment operator =
is accidentally used rather then the comparison operator ==
:
if (bCondition = NULL) // typo here
{
// code never executes
}
if (NULL = bCondition) // error -> compiler complains
{
// ...
}
C-compiler gives a warning in the former case, there are no such warnings in many languages.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…