Re:If Inheritance is so bad, why does everyone use it?
by mrkeen on Saturday April 13, 2024 @04:23AM
(#40021459)
But then I lose polymorphic dispatch, which is where this thread started.
[ Parent
| on HN ]
Re:If Inheritance is so bad, why does everyone use it?
by kaba0 on Saturday April 13, 2024 @05:33AM
(#40021765)
If you pass your object to another function, you only get static dispatch. What you want instead in this case, is a simple instance method. Then yourApple.rotateFruit() would do what you want, and rutateFruit could be an interface method declared in Apple, the superclass/interface.