## in Animal
sub name {
my $either = shift;
ref $either
? $either->{Name}
: "an unnamed $either";
}
named still builds a scalar sheep, so
let's fix that as well:
## in Animal
sub named {
my $class = shift;
my $name = shift;
my $self = { Name => $name, Color => $class->default_color };
bless $self, $class;
}
What's this default_color? If
named has only the name, you still need to set a
color, so you'll have a class-specific initial
color. For a sheep, you might define it as white:
## in Sheep
sub default_color { "white" }