What does this line of code mean?
label.frame = (inPseudoEditMode) ? kLabelIndentedRect : kLabelRect;
The ?
and :
confuse me.
c++conditional-operatorobjective-coperatorssyntax
What does this line of code mean?
label.frame = (inPseudoEditMode) ? kLabelIndentedRect : kLabelRect;
The ?
and :
confuse me.
Best Answer
This is the C ternary operator (Objective-C is a superset of C):
is semantically equivalent to
The ternary with no first element (e.g.
variable ?: anotherVariable
) means the same as(valOrVar != 0) ? valOrVar : anotherValOrVar