On 24 Feb 2012, at 9:52 am, Scott Ribe wrote:

> Now there is one style that is worth defending, which is when comparing a 
> variable to a constant, put the constant first. Consider the following:
> 
> if(self == nil)...
> if(self = nil)...
> if(nil == self)...
> if(nil = self)...
> 
> The 1st & 3rd are the correct conditions, the 2nd & 4th are typos. But the 
> 2nd compiles and gives incorrect behavior, while the 4th fails to compile.

Fortunately the compiler (nowadays) warns in these situations, and suggests 
that one either fix the operator or enclose the expression in extra parentheses 
to clarify the intent.  Personally I enjoy the latter.

b

--
Ben Kennedy, chief magician
Zygoat Creative Technical Services
http://www.zygoat.ca


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to