Re: assignment in if clause (was: alternate pattern for object initializers)
Re: assignment in if clause (was: alternate pattern for object initializers)
- Subject: Re: assignment in if clause (was: alternate pattern for object initializers)
- From: "Hamish Allan" <email@hidden>
- Date: Mon, 26 May 2008 19:40:41 +0100
On Mon, May 26, 2008 at 7:06 PM, Stuart Malin <email@hidden> wrote:
> Even though the double parens make clear that I had intended an assignment,
> it looks odd, and I can't recall ever seeing anything like this -- even in
> numerous example code snippets in the docs that use enumerators. So, my
> question is, is this double paren idiom good, or should I code such while
> loops in yet some other way?
The double-parens idiom is pretty standard, but:
while ((instance = [someEnumerator nextObject]) != 0)
is more explicit, or to avoid implicit return values from assignments
altogether and still keep it to a single statement:
for (instance = [someEnumerator nextObject]; instance != 0; instance =
[someEnumerator nextObject])
Hamish
_______________________________________________
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