如果(X == 0 || 7 || 14 || 21 || -7 || -14){Y =周四;} [英] if (x==0||7||14||21||-7||-14) {y=THURSDAY;}
本文介绍了如果(X == 0 || 7 || 14 || 21 || -7 || -14){Y =周四;}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您可以用一串或公司的一排这样?
Can you use a bunch of or's in a row like that?
if (x==0||7||14||21||-7||-14){y=THURSDAY;}
它似乎并没有对我的工作。
怎么了?可以||不能用于两个否则,如果具有相同的则predicate条件
it doesn't seem to be working for me. what's wrong? Can || not be used for two else if conditions with the same then predicate?
推荐答案
被认为是逻辑真。所以你如果能读到这样:
如果x == 0或真或真或真...
你大概的意思是如果(X == 0 ||点¯x== || 7 ==点¯x14 ...)
in c anything other than 0 is considered boolean true. so your if can be read like:
if x==0 or true or true or true...
what you probably meant was if (x==0 || x==7 || x==14 ...)
这篇关于如果(X == 0 || 7 || 14 || 21 || -7 || -14){Y =周四;}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文