Re: assignment in if clause
Re: assignment in if clause
- Subject: Re: assignment in if clause
- From: Kevin Grant <email@hidden>
- Date: Mon, 26 May 2008 22:37:47 -0500
I agree that it is perfectly clear. But there is still a serious
problem
with it: it is too easy to make the typo of if(a=b) when one intended
if(a==b). This can be a surprisingly difficult typo to spot, when
one is
staring at the code with the preconceived belief that one typed
if(a==b).
The style I adopted is to place the "most constant" part of an
expression first: for example, "if (0 == x)" instead of "if (x == 0)".
This generates a compile-time error for accidental assignments.
Kevin G.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden