control-flow

Why non-equality check of one variable against many values always returns true?

こ雲淡風輕ζ 提交于 2019-11-25 21:42:32
问题 I have a variable v in my program, and it may take any value from the set of values \"a\", \"b\", \"c\", ..., \"z\" And my goal is to execute some statement only when v is not \"x\" , \"y\" , or \"z\" . I have tried, for C-like languages (where equality operators compare the actual string values; eg. c#, javascript, php) if (v != \"x\" || v != \"y\" || v != \"z\") { // the statements I want to be executed // if v is neither \"x\", nor \"y\", nor \"z\" } for Pascal-like languages (e.g. plsql)