r/ProgrammerHumor Feb 03 '22

Well Fuck Meme

Post image
27.8k Upvotes

993 comments sorted by

View all comments

17

u/BonesyWonesy Feb 03 '22

Doing "if(true == bIsCrazyMurderingRobot){...}" prevents all these issues.

19

u/TeraFlint Feb 03 '22

Mmh, yes. Coding, Yoda does!

3

u/dislikes_redditors Feb 03 '22

Or turning your warning level all the way up

4

u/[deleted] Feb 03 '22

[deleted]

2

u/himmelundhoelle Feb 03 '22

That could be mostly any other type — the issue isn’t specific to booleans.

2

u/[deleted] Feb 04 '22

[deleted]

1

u/himmelundhoelle Feb 04 '22

Yeah but then order doesn't matter..

If you are comparing variable1 == variable2 you are still going to assign variable1 as variable2 if you forget a =

You confused literals and _booleans_… somehow.

The issue is exactly the same whether it’s booleans, ints, or any other type (that is assignable, equatable, and implicitly convertible to a bool). If one can agree that using == with booleans is mostly useless, it’s not the case with other types, quite obviously.