Perl 6 Perl 6 today #65

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 © 2009
http://www.pmichaud.com/2009/pres/