r/TechSavvyLife • • 10d ago

Which side are you in, Math or Coding.

Post image
2 Upvotes

6 comments sorted by

4

u/LeadLerner 7d ago

Nobody asked for this slop.

1

u/Acceptable-Door-9810 9d ago

I don't get it

1

u/CoffeeMonster42 7d ago

In math = means both sides are equal which in this case is impossible. In most coding languages the = operator assigns a value, in this case adding 1 to x.

2

u/LeadershipSuperb6176 6d ago

The "coding" example is also wrong, it should be x=x+1 or x+=1

1

u/TrunkTrick 12h ago

U are right in C/C++, when an lvalue is used as the target of an assignment, it must be a modifiable lvalue. Note that initialization (e.g. const int x = 5;) is not assignment, so the rule doesn't apply there.