aboutsummaryrefslogtreecommitdiff
path: root/devel/p5-Class-Multimethods-Pure/pkg-descr
blob: 87d9096a7e5010a45b24e2633b43e58fa39db918 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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).

WWW: https://metacpan.org/release/Class-Multimethods-Pure