• 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: [Obj-C] if (self) vs. if (self != nil)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Obj-C] if (self) vs. if (self != nil)


  • Subject: Re: [Obj-C] if (self) vs. if (self != nil)
  • From: Wade Tregaskis <email@hidden>
  • Date: Fri, 24 Feb 2012 17:12:51 -0800

>    if(nil != (self = [super init]))
>
> Myself I find it elegantly brief and imminently readable.

I don't mind it, but to me it begs the question of what it offers over:

	self = [super init];
	if (self) {

My rationale is, generally you avoid assignments within conditionals because it's just plain awkward.  The if (self = [super init]) pattern is a rare exception, that is justified purely by convention at this point.  If you're going to break that convention, and increase the verbosity to boot, you should probably just revert to fundamentals - i.e. treat it like any other assignment and test.
_______________________________________________

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


  • Follow-Ups:
    • Re: [Obj-C] if (self) vs. if (self != nil)
      • From: Thomas Davie <email@hidden>
References: 
 >[Obj-C] if (self) vs. if (self != nil) (From: Oleg Krupnov <email@hidden>)
 >Re: [Obj-C] if (self) vs. if (self != nil) (From: David Duncan <email@hidden>)
 >Re: [Obj-C] if (self) vs. if (self != nil) (From: Erik Stainsby <email@hidden>)

  • Prev by Date: Delaying touchesMoved
  • Next by Date: Re: [Obj-C] if (self) vs. if (self != nil)
  • Previous by thread: Re: [Obj-C] if (self) vs. if (self != nil)
  • Next by thread: Re: [Obj-C] if (self) vs. if (self != nil)
  • Index(es):
    • Date
    • Thread