Perl 6 Perl 6 today #41

Subroutines, named params

Named parameters are indicated with leading colons

sub catch_plane(:$flight!, :$seat) {
    my $gate = find_gate($flight);
    walk_to($gate);
    board_plane();
    find_place($seat);
}

catch_plane( seat => '7A', flight => 'AA3881' );

Named parameters are optional by default

Use ! to make them required

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