June 2004
Intermediate to advanced
298 pages
12h 19m
English
To declare a subroutine
without
defining it you give it a body consisting of nothing but the
. . . (or “yada, yada,
yada”) operator. So, all the preceding examples that
look like pseudocode with { . . . } for their body
are actually valid subroutine declarations.
sub stubbly (Str $name, Int ?$days) { . . . }When you later define the subroutine, the signature and defined traits must exactly match the declaration.
sub stubbly (Str $name, Int ?$days) {
print "$name hasn't shaved in $days day";
print "s" if $days > 1;
}Read now
Unlock full access