I saw someone ask User? YES: What does NO mean, just talk about a ternary operator
1. Basic format: (Relational expression)? Expression 1: Expression 2;
Execution process: The relational expression is true and return expression 1 The relational expression is false and return expression 2
MZUserApplication *USER;
if (USER?YES:NO){
NSLog(@"yes");
}else{
NSLog(@"no");
}
Explanation: Since USER is not initialized and is a null pointer, it returns expression 2, that is, print no
Give another example
int A = 5;
int B = 3;
int C = A>B?A:B;
NSLog(@"%i",C);
Since A>B is true, return the first expression, that is, C = 5, print 5
Classmates understand