r/ProgrammerHumor • • Feb 03 '22

Meme Well Fuck

Post image
27k Upvotes

993 comments sorted by

View all comments

Show parent comment

9

u/ClikeX Feb 03 '22

It's perfectly fine in Ruby.

18

u/Galactinus Feb 03 '22

As is c and c++. I have made this mistake

5

u/SANatSoc Feb 03 '22

Unfortunately this is such a subtle little fucker, even seasoned devs can make this mistake

1

u/Galactinus Feb 03 '22

Yeah, nine months into my first position as a professional developer… totally missed what was wrong until I saw the comments… sigh, what else has gotten through my PR reviews…

Also, I tend to say true == variable, that way I get a compile error if I mess up.

1

u/SANatSoc Feb 04 '22

Also, I tend to say true == variable

You monster

1

u/Galactinus Feb 04 '22

I am an embedded developer, I don’t get a lot of helps as it is, so I’ve got to make my own where I can.

1

u/Scrial Feb 03 '22

And can be really annoying to find.

15

u/bistr-o-math Feb 03 '22

And perfectly fine in a lot of languages (c, c++, Java, JavaScript)

The value of an assignment is the assigned value. So a=b will assign value of b to a, and (a=b)==b will be true.

This is also why things like a=b=c=d=1 work: will assign 1 to all of the variables a,b,c,d (first assigning 1 to d, the n assigning value of (d=1) to c, and so on

6

u/theDreamingStar Feb 03 '22

Programming sentient robots in Javascript is my new kink.

1

u/sensitivePornGuy Feb 03 '22

With strict mode active, js will throw an error.