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
-
pmso4177yIt's better than
If (condition == false) {
return true;
} else if (condition == true) {
return false;
} -
RAZERZ26797yI don't understand why that's bad, was it in a function? If so, the return true/false might then be used later if you understand me right.
-
RAZERZ26797y@pmso if that's in a function called returnTrueIfNotCondition and you call that condition, you want it to return true if false.
-
valvy527yIn untyped languages, it is possible to have none (python), undefined (JavaScript) or something entirely different(like a string)
Although it depends on the situation and language. -
RAZERZ26797y@Noobish for example, if you want to check if user input contains a string and it does, you would want it to return true from the function, or?
-
RAZERZ26797y@Noobish and then return true, right? But that doesn't look like it would work in a lot of languages
-
The condition was a simple boolean.
The language C#.
It was indeed in a function and I'm not sure why they couldn't simply write:
Return condition: -
@BigAlan09 no reason whatsoever.
It may have happened over time though (multiple refactoring and people not quite checking the whole code)
Related Rants
-
l0om44100% Real. And it's not even the worst on the site.
-
Codazed11Being 100% serious, I saw a guy in my Computer Programming I class using MS Word to write code that he would c...
-
dfox8I worked with a good dev at one of my previous jobs, but one of his faults was that he was a bit scattered and...
I have previously seen this in a production code base. The same code base included nested if statements (20+ conditions)...
If (condition == false) {
return false;
} else if (condition == true) {
return true;
}
rant
wk99