this post was submitted on 11 Dec 2023
32 points (79.6% liked)

JavaScript

2041 readers
1 users here now

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 22 points 1 year ago (4 children)

I often have the pleasure of refactoring this mess. And sometimes it's not just 2 ternaries but like 4 or 5 thrown together. It took like half an hour to even understand what was going on. If you do this, you are just an evil person...

So I totally support this. Stop this shit...

[–] coloredgrayscale 10 points 1 year ago (1 children)

pleasure of refactoring this mess took half an hour to understand

If you can use any of the jetBrains IDE it can rewrite it to if/else with a few clicks (or [alt] +[return])

[–] [email protected] 2 points 1 year ago

Ah that would be helpful. Gotta try that the next time I encounter such a monstrosity.

[–] [email protected] 8 points 1 year ago (1 children)

This shit always leaves me wondering who even writes this crap. The answer is more often than not a junior that just discovered code golf thinking he’s oh so clever. You learn to appreciate boring code, with experience…

[–] [email protected] 5 points 1 year ago

Totally agree with you. I'm always an advocate for boring and easy to understand code.

I really don't need an extra layer of complexity just so someone can save a line or two.

[–] [email protected] 7 points 1 year ago

So I'm pretty sure nested ternaries violate one of the Geneva Conventions' optional protocols.

[–] Lmaydev 1 points 1 year ago

Perfect job for ChatGPT.