aboutsummaryrefslogtreecommitdiffstats
path: root/devel/p5-Class-Multimethods-Pure/pkg-descr
blob: d2568a4e0169dcf192fa1dfecc28b8fa83275d3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
You can define multimethods with the "multi" declarator:

    use Class::Multimethods::Pure;

    multi collide => ('Bullet', 'Ship') => sub {
        my ($a, $b) = @_;  ...
    };

    multi collide => ('Ship', 'Asteroid') => sub {
        my ($a, $b) = @_;  ...
    };

It is usually wise to put such declarations within a BEGIN block, so
they behave more like Perl treats subs (you can call them without
parentheses and you can use them before you define them).