3 ms·
I've seen it used a lot in Objective-C for default values: NSNumber *value = dict[@"key"] ?: @1;
by conradev 13y ago
I've seen it used a lot in Objective-C for default values:
NSNumber *value = dict[@"key"] ?: @1;
- cpeterso 13y ago?: is the "Elvis" operator.
- adamnemecek 13y agoThat's pretty a hilarious name for it. Is this from the Groovy community?
- vorg 13y agoThe standard name is the "Null-coalescing" operator, see http://en.wikipedia.org/wiki/Null_coalescing_operator http://en.wikipedia.org/wiki/Null_coalescing_operator . It's only called "Elvis" in Groovy. The name was announced one day by its Project Manager as part of a marketing campaign to make the name "G-String" mean a string on Elvis's guitar instead of a revealing item of clothing.