3 ms·
I disagree. Polymorphism and inheritance are separate concepts. Yes, some statically typed languages like C++ and Java enforce certain inheritance constraints
by vog 16y ago
I disagree. Polymorphism and inheritance are separate concepts.
Yes, some statically typed languages like C++ and Java enforce certain inheritance constraints via classes or explicit interfaces before you can use polymorphism.
But almost all dynamically typed languages allow for ad-hoc polymorphism. For instance, in Python this is called "duck typing". Just because two objects provide a "foo()" method doesn't mean they are in any inheritance relation to each other. But polymorphism should still work.