== Operator and operands

In most languages it’s the same thing.

People often do 1 == evaluated value because 1 is not an lvalue. Meaning that you can’t accidentally do an assignment.

Example:

if(x = 6)//bug, but no compiling error
{
}

Instead you could force a compiling error instead of a bug:

if(6 = x)//compiling error
{
}

Now if x is not of int type, and you’re using something like C++, then the user could have created an operator==(int) override which takes this question to a new meaning. The 6 == x wouldn’t compile in that case but the x == 6 would.

Leave a Comment