FROM : Hamish Allan
DATE : Mon May 26 20:40:41 2008
On Mon, May 26, 2008 at 7:06 PM, Stuart Malin <<email_removed>> 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
DATE : Mon May 26 20:40:41 2008
On Mon, May 26, 2008 at 7:06 PM, Stuart Malin <<email_removed>> 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 mail archive

