0

I am looking through some Objective-C code and see the following line that doesn't' make sense:

dict ?: @{@"value":value}

What does the ?: mean in this context? I haven't been able to find anything about it anywhere, and it kind of looks like a ternary operator, but without the positive return value. Does this just mean return nothing if dict is non-nil, and the other dictionary if it is nil?

NumberOneRobot
  • 1,691
  • 6
  • 17
  • 23

1 Answers1

0

It's a GNU extension to the C ternary operator and expands to:

dict ? dict : @{ @"value" : value };
Droppy
  • 9,691
  • 1
  • 20
  • 27