in reply to Re^2: Getting the next array element while still keeping the current one
in thread Getting the next array element while still keeping the current one
The loop:
may be slightly too subtle, since we often have loops that look like:for ( my $i = 0; $i < $#array; ++$i )
or:for ( my $i = 0; $i <= $#array; ++$i )
and it would be easy for the eye to pass over that and miss the difference.for ( my $i = 0; $i < @array; ++$i )
I'd be tempted to write it instead as:
to emphasise the departure from the common idiom.for ( my $i = 0; $i <= $#array - 1; ++$i )
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Getting the next array element while still keeping the current one
by tkil (Monk) on May 02, 2004 at 18:07 UTC |