2 ms·
When I go to the link, the top answer is about an if..else where the else will never be called. Searching the page for "left join" finds nothing.
by Joeboy 5y ago
When I go to the link, the top answer is about an if..else where the else will never be called. Searching the page for "left join" finds nothing.
- Brian_K_White 5y agoYou didn't intend to talk about this but... I think it's not necessarily wrong to write a line of code that is never reached, especially for code that may be changed later, and maybe by someone else, which is really all code ever. You might write the no-op or unreachable else branch just so that the placeholder is there, to highlight that it needs to be considered in case the original condition is ever changed. It's only unreachable today with todays condition and maybe even just todays data or maybe even just todays version of the language. Tomorrow another programmer could change the if condition, or the data could start to fall through that condition, or even some implicit behaviour of the language could change which ends up changing how the condition is evaluated.
- Joeboy 5y agoYeah, I've done things like raise Exception("This should never happen") and feel no need to apologize for it.