3 ms·
You 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 c
by Brian_K_White 5y ago
You 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.