335
submitted 1 year ago* (last edited 1 year ago) by AlmightySnoo@lemmy.world to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] deaf_fish@lemm.ee 1 points 1 year ago

Okay, even if I give you the unexpected behavior point. The readability problem remains. Switch statements or tables will work just fine and are easier to read.

To be clear, I am fine with single ternary operations. I think nested ternary operations are harder to read and follow.

[-] Serdan@lemm.ee 1 points 1 year ago

I agree you should use a switch where applicable, but ternaries are the expression equivalent of if-else statements. If I have two conditions and a default, and each branch simply evaluates to a value of the same type, I'll probably just use a ternary.

this post was submitted on 14 Jul 2023
335 points (91.0% liked)

Programmer Humor

32559 readers
608 users here now

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

Rules:

founded 5 years ago
MODERATORS