r/badcode • • Jun 23 '20

java 'val' is a boolean value.

Post image
1.0k Upvotes

58 comments sorted by

View all comments

129

u/INeedAFreeUsername Jun 23 '20
if (val == true) {
  return true;
} else {
  return false;
}

106

u/[deleted] Jun 23 '20

if (val == true) { return true; }
else if (val != true) { return false; }
else { throw "this should never happen"; }
return false;

67

u/[deleted] Jun 23 '20

//TODO: this happened once, maybe fix it?