devxlogo

Put the Constant On the Left Side of the Expression

Put the Constant On the Left Side of the Expression

Always put the constant on the left side of an equality/inequality comparison like this:

 if (0 == Value)

This is a good practice because if you accidentally put the ‘=’ operatorinstead of ‘==’ , then the compiler will detect it. Also, the constant value is right up front where you can see it, not buried at the end of the expression.

devx-admin

Share the Post: