Perl 6 Perl 6 today #24

Iterating n values at a time

The block can also have multiple parameters

This causes the loop to iterate n-at-a-time

my %scores = < pmichaud 52   mäsak 95   PerlJam 78 >;

for %scores.kv -> $name, $score {
    say "$name has $score points";
}

The .kv method returns elements of a hash as a list with interleaved keys and values

See also .keys, .values, and .pairs methods

Copyright © 2009
http://www.pmichaud.com/2009/pres/