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
-
stop68025y0-Level(normal ternary) can be bad.
1-Level(ternary in ternary): bad
2-level++: evil refined in each level. -
HughRant5075y@rant1ng Well, I wouldn’t mind as long as it’s readable. But I must challenge the idea that a nested ternary expression would ever be less convoluted than a series of nested if-blocks.
-
rant1ng44625y@HughRant
To me they are readable...i user them mostly in return statements.. saves me from scrolling to read functions -
functions. use static functions, or something more readable then trenary.
I can live with runtime config flags in ternary, but not in actual code. -
Bad. Ternary is meant to be plain simple. Not to hide 12 if statements.
Okay, originally ternary had a slightly different purpose, but simplicity is very closely related to it. -
C0D4669025yPlease dont.
Don't even joke about this shit.
Ternary operators are fine if done well for a single condition, but nested? There's no way on this god forsaken earth you or the next dev will understand what the hell is going on without breaking it apart slowly later on.
Also I've seen ternary with initiation and assignment so all of a sudden your little shit if() statement you couldn't be bothered writing correctly, now becomes an important piece of the puzzle. -
Root797675yIf they're in parentheses? Tolerable; better with indenting.
If they're not? The author deserves to be stabbed.
Related Rants
nested ternary operators
like/dislike?
I used to hate them cuz I would have to break them apart just to understand them, but now I use ternary operators so much, nesting at least one level is ok for me.
but i'm the only person that reads my code, what's the concensus.. nesting one level bad?
I wouldn't want someone reviewing my code if they couldn't wrap their head around a simple ternary, so if only myself or people more experienced than myself will ever read them, then fuck it, i'm using them
question
more than meets the eye
transformers
ternary operators