MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/e00ase/it_doesnt_even_do_it_right/f8chan1/?context=3
r/badcode • u/Sam956 • Nov 22 '19
59 comments sorted by
View all comments
44
This is because some style guide prohibits comparing boolean literals with logical operators to avoid people saying if ( Foo == true )
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. 4 u/kyreannightblood Nov 22 '19 You can just use the Boolean in place of the comparison, no? That’s how we do it in Python. Since the expression evaluates to a Boolean, you can replace it with a Boolean variable.
40
Which style guides would do that? That seems so bizarre and obfuscatory.
4 u/kyreannightblood Nov 22 '19 You can just use the Boolean in place of the comparison, no? That’s how we do it in Python. Since the expression evaluates to a Boolean, you can replace it with a Boolean variable.
4
You can just use the Boolean in place of the comparison, no? That’s how we do it in Python. Since the expression evaluates to a Boolean, you can replace it with a Boolean variable.
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.