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
-
cuddlyogre142118hIt gets worse the longer you look at it. Returning a string and not a boolean is making my skin crawl.
-
retoor650518hI wont. But i will do one or two, based on my mood.
Btw, who the fuck are you? Welome back i guess :) -
Lensflare1943518h1, 2, 3 depends on the case. For short stuff ternary is ok. For longer stuff, if else. For early returns "2" is ok.
4 is a no go as it utilizes mutation for no good reason.
5 seems fabricated. No one would use that (i hope)
6 seems similarly fabricated. Who would use switch for a boolean condition? -
Lensflare1943518h@cuddlyogre you made me realize that it doesn’t return bool. I assume it was a mistake ^^
-
retoor650517h@12bitfloat yeah, new server doesn't seem that stable. My laptop at home has stable ssh connection for days but my new server doesn't.
-
1: correct. Normal and good. Not great, you could use a lambda.
2. Kinda weird. You probably eat your own dickcheese.
3. You're sort of ok but I still don't like you.
4. What the absolute shit is wrong with you?????? WHY would you do that at all. Your mummy probably shaked you real good and now your brain is compressed you FUCKING weirdo. I HATE YOU!! NOW IM GONNA HAVE TO GO TO SLEEP HAVING SEEN THAT SHIT. IF I EVER SEE THAT SHIT AGAIN I CHALLENGE YOU TO A DUEL!!!!!!!!!!!
5. Kinda smart, but you're a showoff, which mean you have a limp dick. I will still judge you.
6. Booooring. Go buy a butt plug and live a little. -
I like 6, 1, and 2.
Bad function name too. isEven() or isOdd() would read better (it would return a bool value)
It breaks single responsibility principle a bit as it's handling both a "calculation" (if it can be called that) to determine a state AND it's then handling formatting that in some kind of human readable _response_
This is by no means the worst code I've seen but it isn't great -
spongessuck622715hIf this is Typescript, the analyzer will treat the return type as a sort of enum, 'Even' | 'Odd'. It's still weird in this use, but in practice it wouldn't be bad.
-
jestdotty673515hI would rather anonymous function / lambda instead of function
and that switch statement makes me want rust's match
also typing "return". oh no I can never go back now -
CoreFusionX369215hYou know that using a switch instead of an if is a performance hit, right?
Before someone comes to nitpick, I know the compiler will likely elide it, that it is a miiiiinor performance gain otherwise, and yadda yadda yadda.
If no one's life depends on it, just do whatever. Chances are whoever comes next to you is gonna give you shit no matter what choice you pick. -
SidTheITGuy991310hyou forgot the part where you ask GPT
npm i is-odd
this package will do it for you easy peasy. -
3: ok. 1: also ok. 2: no. 5: wtf but I kind of like it. 4: fuck off. 6: fuck off.
-
Jabb032537h1, 2, 3, 6, 4, 5
If I didn't have the other examples, I woudln't even get what 5 does.
Related Rants
Rank Best to worst code readability
Mine 6,3,1,4,2,5
joke/meme
readability
code