4 ms·
I've come to hesistently accept nested ternaries, but I try to have all lines lead with a colon. This kinda mimics a switch statement with returns. firstPoss
by mekkkkkk 6y ago
I've come to hesistently accept nested ternaries, but I try to have all lines lead with a colon. This kinda mimics a switch statement with returns.
firstPossible ? thenThis
: secondPossible ? thenThisOtherThing
: thirdPossible ? thenThisThirdThing
: defaultThing
Always fun to see how people treat ternary nesting. They still feel a bit naughty to me. The terseness is sort of unbeatable though.
- Kkoala 6y agoIt's funny how people have so many different preferences for ternary formatting. I can't think of any other operator that would have tens of different format prefs.