Considering that all three variables have identical values, one would expect the following comparison to result in YES:
NSUInteger count1 = 2;
NSUInteger count2 = 2;
NSUInteger count3 = 2;
BOOL countEqual = (count1 == count2 == count3);
// but: countEqual = NO
Alas countEqual is NO and I’d like to better understand why and whether this particular issue also appears in C or C++ code?
My guess is:
(count1 == count2) --> YES (1)
(YES == count3) or (1 == count3) --> NO (0)
The other posters have already provided the answer, so I’ll just quote the relevant part of the spec that confirms it:
Equality is left associative, so it’s interpreted as: