r/badcode • • Jun 23 '20

java 'val' is a boolean value.

Post image
1.0k Upvotes

58 comments sorted by

View all comments

69

u/Bluebearsuper Jun 23 '20

CONTEXT: This function is inside a class which wraps a boolean. There is another function (really should have included that now that I think about it) that returns val. They will return the exact same thing, and the '== true' part is pointless.

13

u/Siggi_pop Jun 23 '20

Sure it's pointless, but it doesn't affect performance and at best, it highlights to the reader that val is indeed a bool, so you don't have to look elsewhere for that information. So basically, it's not so bad.

18

u/oxetyl Jun 23 '20

You already know val is a boolean because isTrue is declared as boolean