Perl 6 Cool Perl 6 #13

Iterating lists

Use for to iterate over things that provide iterators

Each item is passed to the block

my @suits = <Clubs Diamonds Hearts Spades>;

for @suits {
    say $_;
}

Or as a statement modifier

say $_ for @suits;

Method calls without explicit invocant use $_:

for @suits { .say }       # block form
.say for @suits;          # statement modifier form
Copyright © 2010
http://www.pmichaud.com/2010/pres/