Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4669023ybetter then
bool valid = false;
If(condition1 == true){
if(condition2 == true){
valid = true;
}
else{
valid = false;
}
}
else{
valid = false;
}
My eyes bleed most days. -
One day I found a line like that in our codebase… immediately checked git blame cause I wanted to know who the duck does that: it was me myself.
Though in my defense, judging from the date, it must’ve been one of my first commits ever to any codebase. And then I was left to wonder how nobody mention it at PR.. -
@Shadowleaf seriously, you don’t see what’s wrong with that? Hint: it’s not the assignment…
-
iiii90853y@Shadowleaf the tested result is already a boolean. There's to need to test it and return a boolean yet again.
-
C0D4669023y@Shadowleaf the true/false implicitly returned is redundant.
x = (condition1 && condition2)
Is more then enough. -
bioDan56223y@iiii so tell me what does the following evaluate to?
const areYouSureImBool = (true && {})
const areYouSureImBool2 = (true && '')
const areYouSureImBool3 = (true && []) -
bioDan56223y@100110111 im not saying its not, im just saying there are cases where its valid to be that explicly in JS
-
bioDan56223y@100110111 btw, its only speculation but i bet you can find shit in 85% of code bases
-
Shadowleaf33y@100110111 For some reason was looking what's wrong with comparisons, not type. Guess i need to wake up before posting.
-
@bioDan I guess that’s a way to handle those cases, yes. Does lead to the question whether JS is ever a valid language choice, really. 😏
-
bioDan56223y@iiii this post is about shitcode, its in the tags
i hope you now understand there are use cases where its valid, and that it depends on the type of the second condition.
JS is a weak and dynamic type programming language, lamentably there are cases where this is a valid solution.
Related Rants
someBoolean = (condition1 && condition2 ) ? true : false;
O.M.G....
rant
shitcode