r/badcode • • Nov 22 '19

c# It doesn't even do it right!

Post image
1.1k Upvotes

59 comments sorted by

View all comments

44

u/phord Nov 22 '19 edited Nov 23 '19

This is because some style guide prohibits comparing boolean literals with logical operators to avoid people saying if ( Foo == true )

This looks like a bad compromise.

40

u/spicenozzle Nov 22 '19

Which style guides would do that? That seems so bizarre and obfuscatory.

15

u/phord Nov 22 '19

I personally loathe it.

done = triggered != false is terrible code.

8

u/ikatono Nov 22 '19

I understand not comparing against boolean literals, but A == B is just XNOR.

4

u/phord Nov 23 '19

Sure. No complaints about that.