Re: self = [super init] debate.
Re: self = [super init] debate.
- Subject: Re: self = [super init] debate.
- From: Hans van der Meer <email@hidden>
- Date: Sun, 10 Feb 2008 23:26:05 +0100
On 10 feb 2008, at 22:44, Jens Alfke wrote:
It's possible to coalesce the first two lines into "if( self =
[super initWithFoo: foo] )", but I avoid this because putting
assignments inside 'if' or 'while' tests is a dangerous idiom ...
it's very easy to type "==" instead of "=" and end up with a
difficult-to-detect bug.
It is no problem if one takes care to phrase the if as:
if (nil != (self = [super init])){...}
I know, still more keystrokes, but programming safety is the more
important consideration here and I force myself to not being lazy.
By the way. Doing (nil !== ...) is a habit that saves one in comparing
to variables as in (nil == myvariable). Compare this to (myvariable ==
nil) that indeed is a bit dangerous.
I hope this comment is not too far off topic for this list -- so I
make this my last contribution on this subject.
Hans van der Meer
_______________________________________________
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