Greg Greg - 8 months ago 48
Objective-C Question

does objective-c have an even shorter way of writing this line of code?

does objective-c have an even shorter way of writing this line of code?

a = b ? b : c;


That is a way to say, a is equal to b as long it is not nil, else c. That is, is there anything like ruby's operator "||="

Answer

Does the following work for you:

a = b ? : c;

(This syntax is a GNU extension to C, so you might have to use the GCC and not LLVM - http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Conditionals.html#Conditionals).