Perl 6 Cool Perl 6 #84

Subroutines, optional params

To indicate a parameter is optional, suffix it with ?

sub speak($phrase, $how_loud?) { ... }

Or, give it a default value:

sub greet($name, $greeting = "Hello") {
    say "$greeting, $name";
}

greet('Robert');               # Hello, Robert
greet('Patrick', 'Bonjour');   # Bonjour, Patrick
Copyright © 2010
http://www.pmichaud.com/2010/pres/