开发者

How do I make AND or OR expressions?

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?


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


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


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

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

Your second example is not C or Objective-C

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜