Re: C question for you old guys ;-)
Re: C question for you old guys ;-)
- Subject: Re: C question for you old guys ;-)
- From: Steve Bird <email@hidden>
- Date: Mon, 9 Jun 2003 09:58:03 -0400
On Monday, June 9, 2003, at 08:43 AM, Dan Sugalski wrote:
At 11:30 AM +0200 6/9/03, Marcel Weiher wrote:
I guess I should have been a little more explicit. I wouldn't do
either of the above, but rather:
if ( spriteInfo == NULL ) {
return nil;
}
Having been bitten by C's block issues before, I do that as well, but
I try and take it one step further and do:
if ( NULL == spriteInfo ) {
return nil;
}
putting the constant on the left-hand side of the equality test. It
catches the times when I miss a = in the test--"NULL = foo" throws a
compile-time error, "foo = NULL" leads to a bughunt session.
--- I wrestled with this and came out against it.
Mainly because it goes against "natural" thinking: I always think
if (changeReceived == 31 cents)
{ ThankCashier(); }
else { Complain(); }
I can NOT turn it around to say:
if (31 cents == changeReceived) { }
Since I would have to slow down and think about it anyway, I just make
sure I use the double equals to begin with. The code reads a whole lot
better, IMHO.
----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.