Perl 6 Perl 6 today #23

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 © 2009
http://www.pmichaud.com/2009/pres/