3 ms·
Yeah, I get that that's the intent, but (per my original comment) I'd think it would surely create more mess than it cleans up. For example, I suspect that thr
by fenomas 9y ago
Yeah, I get that that's the intent, but (per my original comment) I'd think it would surely create more mess than it cleans up.
For example, I suspect that three-way IFs like you describe would only really get used in two ways - often the second and third branches would be identical, and the rest of the time the third branch will be some kind of "console.warn('bad inputs!')" kind of error handling.
For the latter of those two cases, testing for the error case before proceeding to the regular logic (as in your code sample above) seems intuitively like the right thing to do - analogously to how you might check (isNaN(operand)) before doing some math. And in the former case, if the second and third branches are identical you'd almost certainly want some syntactic sugar to avoid writing the same logic twice, like "IF (bool) {...} ELSE-AND-OTHERWISE {...}" -- which would just be isomorphic to what we have now. You know what I mean?