r/ProgrammerHumor • • Mar 15 '22

static bool isCrazyMurderingRobot = false;

/img/2g1k34ok5kn81.jpg
4.9k Upvotes

256 comments sorted by

View all comments

1

u/[deleted] Mar 16 '22

I saw a tip a while ago to avoid accidental assignment when one side is a constant. Just flip the order: “if(5 = x)” won’t compile. Thought it was a neat trick.

In practice, if I’m remembering to do that, it’d also remind me to double check my == as well, which is probably the real value.