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
精彩评论