4 ms·
What mistake is that? The left hand variable equals the right hand value assigned to it. Foo = bar and 1 = 1 are equivalent in my mind.
by purple-again 7y ago
What mistake is that? The left hand variable equals the right hand value assigned to it.
Foo = bar and 1 = 1 are equivalent in my mind.
- pbhjpbhj 7y agoSo 2 = 1? How do you square that circle, "fine" for assignment; wrong for equality.
- ken 7y agoThe mistake is assuming "=" is a statement of fact (as in mathematics), rather than a request for assignment (as in programming). Depending on which programming language you're using, "foo = bar" can mean either "make foo now equal to what bar is" or "is foo equal to bar now?". Neither one is the same as in mathematics, which is "foo is categorically equal to bar". Consider: foo = 1 bar = 2 foo = bar In mathematics, this would be a logical contradiction, and either you'd realize you made a mistake, or you'd jump back to the step where you said "now assume ..." and say "now we've proven this can't be true". In programming, this is perfectly valid, and means "ok, ignore what I wrote just 2 lines ago, and now make foo equal to 2, also". You say you think it means "the LH var equals the RH value assigned to it", but you don't say what you think it means to assign to the literal 1.
- purple-again 7y agoThank you for your well thought out explanation! It is clear now and I was committing the cardinal sin of speaking generally while assuming context that was explicit only to my understanding of the situation. Have a great day!