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
-
SidTheITGuy9705325dTeeechnically I wrote it twice, and you know that two negatives make a positive.
Haha, checkmate fam. -
Lensflare17551325dIf the condition is a long expression, then this is better. But then it’s even better to store it in a variable with a meaningful name and then return it directly:
let iAmBraindead = myIQ <= 0 || myName.startsWith("o") && myName.endsWith("m")
return iAmBraindead -
shovethisrant5987325dWho cares - the only thing I really care about is if our code is simple, explicit, and easy to understand for better team cohesion
-
Demolishun35074325dbool rantIsGhey(bool gatekeeping){
bool ghey
if(gatekeeping){
ghey = true
}else{
ghey = false
}
return ghey
} -
Parzi8663325di'm partial to returning an object or False if a failure occured. it's like returning null but it won't break shit if you try to do other things with it, so you can be a little late in error handling if required for whatever reason. This doesn't apply if you have a language that doesn't have auto-casting, however.
The second you write `else { return false; }` you should lose the privilege of calling yourselves a dev, from then on. Period.
Example,
if(condition) {
// ...some code
return true;
} else {
return false;
}
rant