mixin
我不知道和mixin::with
模块有什么区别?
package Dog;
sub speak { print "Bark!\n" }
sub new { my $class = shift; bless {}, $class }
package Dog::Small;
use base 'Dog';
sub speak { print "Yip!\n"; }
package Dog::Retriever;
use mixin::with 'Dog';
sub fetch { print "Get your own stinking $_[1]\n" }
package Dog::Small::Retriever;
use base 'Dog::Small';
use mixin 'Dog::Retriever';
my $small_retriever = Dog::Small::Retriever->new;
$small_retriever->speak; # Yip!
$small_retriever->fetch('ball'); # Get your own stinking ball
在上面的代码中,可以有以下代码:
package Dog::Small::Retriever;
use base 'Dog::Small';
use mixin 'Dog::Retriever';
换成下面的?
package Dog::Small::Retriever;
#use base 'Dog::Small';
use mixin:with 'Dog::Retriever';