Re: RFC 120 (v2) Implicit counter in for statements, possibly $#.
[email protected] ((Johan Vromans)) 19 Aug 2000 11:06:29 +0200
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <[email protected]> |
Mike Pastore <[email protected]> writes: > I like the proposed syntax! I also think that C<keys @array> would be > useful, ... Seconded. It nicely fits in the current way each() is used and no backward incompatibilties. Especially when iterating sparse arrays. while (($index,$value) = each(@sparse_array)) { print "sparse_array[$index] = $value\n"; } would be much more efficient as $index = -1; foreach (@sparse_array) { $index++; next unless exists $_; print "sparse_array[$index] = $_\n"; } I also second the use or keys() and values() for arrays. It fits so nicely. Plus the added benefits if the array is sparse. -- Johan