[Pdx-pm] multi-method dispatch in rakudo

David E. Wheeler david at kineticode.com
Mon Sep 15 10:50:39 PDT 2008


On Sep 12, 2008, at 23:18, Eric Wilhelm wrote:

>  ./perl6 -e '
>    multi sub foo(Int $x) { 1 }
>    multi sub foo(Int $x where { $^n > 42 }) { 2 }
>    say foo(12);
>    say foo(45);'
>
>  ./perl6 -e '
>    role Explode { }
>    class Firework does Explode { }
>    class Kitten { }
>    multi sub bar(Explode $x) { 1 }
>    multi sub bar(Kitten $x) { 2 }
>    say bar(Firework.new);
>    say bar(Kitten.new);'

Awesome. I just did this. Nice to see that this stuff is coming along!

Best,

David


More information about the Pdx-pm-list mailing list