This is not bad code. It is "slightly inelegant" but more readable code (because it is a only return from a function). If would be "inelegant" when used in a if, say in: if (val==true). It starts to be bad when reaching levels of if (val==true) return true; else return false;
I think you don't understand what the problem with this code is. It isn't the comparison, rather its the fact that someone built an entire function around a builtin operator that uses said operator.
-2
u/F54280 Jun 23 '20 edited Jun 23 '20
This is not bad code. It is "slightly inelegant" but more readable code (because it is a only return from a function). If would be "inelegant" when used in a if, say in:
if (val==true). It starts to be bad when reaching levels ofif (val==true) return true; else return false;But a simple comparison with true? Absolutely not worth of a post here. Here are 663000 occurrences using a simple google search
Edit: lol @downvoters that have no idea what actual badcode looks like