Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "and" keyword mean in Objective-C?

I was typing a comment in Xcode, but forgot the leading //. I noticed that and was highlighted like a keyword. I did a bit of Googling, but I can't seem to figure out what it does (or even if it's a real keyword).

What does it mean?

like image 913
paulrehkugler Avatar asked Sep 03 '13 18:09

paulrehkugler


People also ask

What is plus and minus in Objective-C?

The leading minus sign (-) tells the Objective-C compiler that the method is an instance method. The only other option is a plus sign (+), which indicates a class method. A class method is one that performs some operation on the class itself, such as creating a new instance of the class.

What does __ block do in Objective-C?

The __block Storage Type __block variables live in storage that is shared between the lexical scope of the variable and all blocks and block copies declared or created within the variable's lexical scope.

How do you do or in Objective-C?

Objective-C uses all of the same logical operators as C. || is the logical-or operator.

Can I use C in Objective-C?

You really can't use C in Objective-C, since Objective-C is C. The term is usually applied when you write code that uses C structures and calls C functions directly, instead of using Objective-C objects and messages.


2 Answers

It's a synonym for &&. See iso646.h.

like image 141
Rob Napier Avatar answered Sep 23 '22 15:09

Rob Napier


It is not a keyword. Objective-C shares exactly the same keywords as C with additional ones that always start with '@'.

EDIT: This question doesn't answer the original post (see Rob Napier's succint answer for this), but rather it highlights that 'and' is a macro in some standard library headers and not a reserved word.

Quote from the C standard (C11, n1570), page 58:

6.4.1 Keywords

keyword: one of auto, break, case, ... [list of words not including 'and']

like image 44
Cthutu Avatar answered Sep 20 '22 15:09

Cthutu