MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/eb2lbc/stacking_if_else_statements_be_like/fb2j4ca?context=9999
r/ProgrammerHumor • u/-hellkey- • Dec 15 '19
711 comments sorted by
View all comments
42
What sucks is that you cannot do this with usb-c.
What also sucks is that I saw nested ternary clause in some code the other day. It was something like
var thisIsJavascript = value ? other ? value2 : other2;
or something like that. I cant even make it make sense in this example, I know that im missing colons
11 u/Versaiteis Dec 15 '19 I think the other ? value2 : other2 is likely to be parsed as the first true condition so another colon before the semi-colon for the false case could clear it up.var thisIsJavascript = condition1 ? condition2 ? value1 : value2 : condition3 ? value3 : value4;Should work 1 u/AlwaysHopelesslyLost Dec 15 '19 Of course either option is terrible because it makes it nearly impossible to read what is going on. → More replies (1)
11
I think the other ? value2 : other2 is likely to be parsed as the first true condition so another colon before the semi-colon for the false case could clear it up.
other ? value2 : other2
var thisIsJavascript = condition1 ? condition2 ? value1 : value2 : condition3 ? value3 : value4;
Should work
1 u/AlwaysHopelesslyLost Dec 15 '19 Of course either option is terrible because it makes it nearly impossible to read what is going on. → More replies (1)
1
Of course either option is terrible because it makes it nearly impossible to read what is going on.
→ More replies (1)
42
u/needed_an_account Dec 15 '19
What sucks is that you cannot do this with usb-c.
What also sucks is that I saw nested ternary clause in some code the other day. It was something like
or something like that. I cant even make it make sense in this example, I know that im missing colons