Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this the correct approach?

    BOOL end = mask & NSEventMaskEndGesture ? YES : NO;


I think, not!!

   BOOL end = !! (mask & NSEventMaskEndGesture);
Like a little pair of surprised eyes.

Also works for pointers:

    BOOL hasError = !! errorObj;


(mask & NSEventMaskEndGesture) == NSEventMaskEndGesture is the most correct, as it handles the case where NSEventMaskEndGesture has multiple bits set.


or just != 0




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

Search: