• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: self = [super init] debate.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >self = [super init] debate. (From: Scott Andrew <email@hidden>)
 >Re: self = [super init] debate. (From: Quincey Morris <email@hidden>)
 >Re: self = [super init] debate. (From: Ricky Sharp <email@hidden>)
 >Re: self = [super init] debate. (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Asynchronous Distributed Object Calls
  • Next by Date: Re: self = [super init] debate.
  • Previous by thread: Re: self = [super init] debate.
  • Next by thread: Re: self = [super init] debate.
  • Index(es):
    • Date
    • Thread