The what?
We sometimes write code like:
NSString* someValue;
//...
NSString* val;
if (someValue) {
val = someValue;
} else {
val = @"some default";
}
or similarly, using the tenary operator:
NSString* someValue;
//...
NSString* val = someValue? someValue: @"some default";
You can leave out the middle operand of the tenary operator like this and it'll work as before:
NSString* someValue;
//...
NSString* val = someValue?: @"some default";
This special form of the tenary operator is known as the null coalescing operator in some languages.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.