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
-
jdmng0689y@iam13islucky Well, *nested* ternary operators aren't faster to read when debugging than to just use a simple if-else statement. I've been using ternary operators in my codes but I try to stick with shorter conditions. -
px0622319yI'd only use them for small things where it's obvious what's being done. Not for huge logic where switch or if statements would be a lot more readable and easy to debug. What's the point of writing short code and then spending hours going through it when something doesn't work because it isn't debuggable? -
Root772319yNested ternaries aren't difficult to read if you add parenthesis around each.
If you don't, they're annoying.
Related Rants

They chose mine! THEY CHOSE MINE!
string action = day == "Monday" ? "Go to work" : "Friday" ? "Netflix & chill" : "Saturday" ? "Sleep all day" : "Sunday" ? "Get ready again for Monday" : "Code from 9-5";
I wrote nested ternary operators before and I swear I'd only use shorter conditions like the one below. 😳
string action = isTired == true ? "Get some sleep" : "Drink more coffee";
undefined
wk47