Luke Palmer wrote:
> Huh? You don't have to check it explicitly. Cat doesn't support the
> bark() method, so it can't be used as a Dog. And the type system will
> see that. End of story.
There are, however, problems with an interface approach. For example:
class Dog {
method breathe() {...}
method feed() {...}
method grow() {...}
method bark() {...}
method reproduce() {...}
method die() {...}
}
class Oak {
method breathe() {...}
method feed() {...}
method grow() {...}
method bark() {...}
method reproduce() {...}
method die() {...}
}
my Oak $tree = Dog.new();
my Dog $spot = Oak.new();
:-(
Damian
Thread Previous
|
Thread Next