Perl 6 Perl 6 #19

Subroutine formal parameters

Perl 6 has explicit parameter checking:

Positional parameters:

sub my_func ($x, $y, $z) { ... }

Explicit typing:

sub my_func (Animal $x, Dog $y, Any $z ) { ... }

Optional parameters:

sub my_func ($x, $y?, $z = 3) { ... }
Copyright © 2008 Patrick Michaud