开发者

How do I make AND or OR expressions?

开发者 https://www.devze.com 2023-03-08 08:16 出处:网络
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 o

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

精彩评论

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

关注公众号