Perl 6 Cool Perl 6 #14

Pointy blocks

Blocks can take parameters

"Pointy blocks" allow naming the arguments to a block

my @suits = <Clubs Diamonds Hearts Spades>;

for @suits -> $suit {
    say $suit;
}

The parameter is local to the block

"Placeholder variables" can also be used, indicated by ^

for @suits { say $^x; }    # $^x is parameter to the block
Copyright © 2010
http://www.pmichaud.com/2010/pres/