Hi,
What is the answer to "nil%2" in objective-c? I think the answer is 0 but I am not sure.
Thank you.
Hi,
What is the answer to "nil%2" in objective-c? I think the answer is 0 but I am not sure.
Thank you.
It's impossible for a mod-2 operation to return 2—only 0 or 1. I would assume, in this case, that it would be 0.
Actually the answer is a compiler error. nil
is a pointer (it is defined as (void *)0
), and the only arithmetic operations defined for pointers are addition and subtraction. But if you wanted to know what 0%2 is Noah’s answer is right.