Perl 6 Cool Perl 6 #92

Arity-based dispatch

"Arity" is the number of arguments that a routine takes

multi sub greet($name) {
    say "Hello, $name!";
}

multi sub greet($name, $greeting) {
    say "$greeting, $name!";
}

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