Operators can be divided into the following types:
Arithmetic operators: +,-, *,/,%,++,—-。
Relational operators: <,>,<=,>=,==,!=
Boolean logical operators:! , &&,| |
Bitwise operator:|,&,^,~,>>,<<
Assignment operators: + =,-=, *=, =/
Conditional operator:?:
Attention:
1. There are two more special operator symbols in the boolean logical operators, "&&" and "| |".
Where the "&&" is short-circuited and if the two expressions are computed, if the value of the first expression is false, it is independent of the value of the second expression and the result is definitely false, so that the second expression is no longer evaluated.
"| |" For short-circuiting or, if two expressions are evaluated, if the value of the first expression is true, the structure must be true, regardless of the value of the second expression, so the second expression is no longer evaluated.
2. Examples of bitwise operators:
3. Conditional operators
The format is: boolean expression? Expression 1: Expression 2
When the value of a Boolean expression is true, the value of expression 1 is returned, otherwise the value of expression 2 is returned.
Objective-c Operators and expressions