Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.
[email protected] ((Johan Vromans)) 30 Aug 2000 16:18:58 +0200
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <[email protected]> |
John McNamara <[email protected]> writes: > As far as I can see the current consensus is as follows: > 1. Implicit variable: nice but not really worth the trouble. > 2. Explicit variable between foreach and the array: might conflict > with other proposals. > 3. Explicit counter in the body of the for/each loop: a clean > solution but requires a new or reused function. What happened to the --nice, elegant and sparse array friendly-- extension of each/keys/values? for ( ($i,$v) = each(@a) ) { print "Value $v at index $i\n"; } foreach ( keys @a ) { print "Value $a[$_] at index $_\n"; } -- Johan