I occasionally see questions about this common mistake but cannot find an appropriate canonical for the language the question is in.
I have seen: Canonical, language-agnostic question for if(var != "x" || var != "y" ...)
That question asks a canonical for questions about themistakes caused by incorrectly assuming that if (x !=== a || x != b ...|| c)
and resulted in one being created: Why does non-equality check of one variable against many values always return true?
The question also mentions a similarmeans if (x == a || x == b || cx ...== c)
problem,but cannot find an appropriate canonical for which severalthe language the question is in.
Some canonical questions exist, but only for specific languages:
What should be done about miscellaneous questions caused by the if (x == a || b || c ...)
problem for languages that do not haveWhy is there a language-agnostic canonical? Here are some ideas that come to mind for a very similar issue but might not be good ideas for various reasons:
- Should a new language-agnostic canonical be created for those? This would require a lot of effort and might not be necessary.
- Should a new language-specific canonical Q&A be created for each and every new language I see about this problem? Some less widespread languages might not encounter this problem often enough to warrant a new canonical Q&A for each one and there will be a lot of redundant information.
- Should they be closed as a duplicate of Why does non-equality check of one variable against many values always return true? Though the underlying cause of the problem is different and the other question might need to be modified to include
if (x == a || b || c ...)
cases.
- Should they be closed as a duplicate of a canonical of a different language? This would be confusing as the users directed to them would see solutions not relevant to their use case.
- Should they be closed as Not reproducible or caused by a typo? This would not direct the author to an appropriate resource to learn more about the problem unless someone leaves a comment.
Ifthis one? What should I am correctdo find a question that these ideas are not the best what should be done insteadis caused by that mistake but no language-specific canonical exists?