Hacker News new | past | comments | ask | show | jobs | submit login

I've seen it used a lot in Objective-C for default values:

    NSNumber *value = dict[@"key"] ?: @1;



?: is the "Elvis" operator.


That's pretty a hilarious name for it. Is this from the Groovy community?


The standard name is the "Null-coalescing" operator, see 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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: