I have fixed a lot of bugs due to "elseif" over the decades in various languages. The person who came up with that construct should endure the Confy Chair.
I have fixed a lot of bugs due to "elseif" over the decades in various languages. The person who came up with that construct should endure the Confy Chair.
If we didn't have else-if, somebody will certainly lament "If we had something called else-if, I'd not have fixed a lot of bugs due this complex condition statements in various languages. The person who opposes implementation of such a simple construct should endure the Confy Chair".
So, it goes both ways.
Moreover, else-if is probably the most misused conditional, so while I disagree that it shouldn't exist (it has some uses), GP has a point.
Although linters now are good enough now to catch poorly used conditionals, so his point is way less relevant than it was a decade ago.
Depends on the code base and problem domain you code / live in. In most cases you're right, but in my domain it's a different story.
> Moreover, else-if is probably the most misused conditional
You can misuse anything in any language, so by this logic we should argue that we shall abolish all programming altogether. I can misuse threads to make a program slower, misuse memory allocator to fragment the memory, etc. etc.
So I don't think "but people misuse it" is a great argument either.