Re: [Obj-C] if (self) vs. if (self != nil)
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