Hi all, please consider this:
package Foo { use strict; use warnings; use Class::Tiny; 1; } __END__
package Bar { use strict; use warnings; use Class::Tiny; 1; } __END__
package Methods { use strict; use warnings; use feature qw(isa); use Logic::Easy; no warnings qw(redefine); sub frobnicate : Multi(frobnicate) { SIG [$o] where {$o isa 'Foo'}; qq(foo); } sub frobnicate : Multi(frobnicate) { SIG [$o] where {$o isa 'Bar'}; qq(bar); } 1; } __END__
#!/usr/bin/env perl use strict; use warnings; use lib q(.); use Bar; use Foo; use Methods; use feature qw(say); my $gizmo = Foo->new(); my $mojo = Bar->new(); # dd $gizmo, $mojo; say Methods::frobnicate($_) for ($gizmo, $mojo); __END__
As expected, frobnicate cannot be imported - "there can be only one". Also with Methods->frobnicate() it does not work. Remains only Methods::frobnicate() - as to see. Or is there something else I have overlooked?
«The Crux of the Biscuit is the Apostrophe»
In reply to How to bring in multimethods by karlgoethebier
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |