How do I make AND or OR expressions?

≡放荡痞女 提交于 2019-12-01 01:00:38

问题


I wrote this:

if( a == -11 && b == -1 ){
{

if( a == -1) AND ( b == -1)...

But neither work, and I have the same problem with OR. How do I write expressions that include OR or AND?


回答1:


You use && for “and”, and || for “or”.




回答2:


(a == -11 && b == -1) is fine and correct. Objective-C uses all of the same logical operators as C. || is the logical-or operator.




回答3:


if (a==-11 && b==-1) {

if perfectly legal in C, and therefore Objective-C.

Your second example is not C or Objective-C



来源:https://stackoverflow.com/questions/6118338/how-do-i-make-and-or-or-expressions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!