this post was submitted on 14 Jul 2023
349 points (91.4% liked)

Programmer Humor

32730 readers
524 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

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

ternaries are usually more flexible than switches

Which is bad for readability because the reader need to manually compute it to see whether it's doing simple switching or not. Also it adds the question of "Why did the author use a nested ternary instead of a switch? Was it meant to do more but it got left out unintentionally?"

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

Yes, you need to read code to understand it. If else statements can also do the job of a switch, so the exact same argument applies.

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

The point is I don't need to read a switch statement to know that it is a switch