The main reason for this, I believe, is to prevent errors such as:
if (variable = 0)
Where you assign in a state instead of a comparison. The reason is that this will not work otherwise, because you have a constant on the left side of the expression.
So, if you mistakenly write:
if (0 = variable)
You got a compilation error while trying to assign something to a constant.
In my opinion, this is more important in terms of programming style, but it can still be good advice for new programmers. But as soon as you are a little more experienced, errors like this do not occur, and if they do, you should easily track them.
source share