This might sound like a joke, but it’s actually not. First, let’s define inheritance. Inheritance is the ability to use polymorphism to override a method with another implementation. You inherit from a class, and you override one of its virtual functions. This results in that code having an object that will no longer invoke the old base class method, but rather the new overridden method. Kind of easy, right?

Polymorphism Is the Ability To Have Old Code Invoke New Code

Well, there’s nothing intrinsically special about class-based OOP that prevents you from implementing the above in a functional context. In a functional programming language, you can have a reference to a function, and replace the function it’s pointing to, before passing in your function reference to some method in need of a function with the specified signature. This achieves the exact same result as « classic polymorphism. »

Source de l’article sur DZONE

L’assistance proposée par ANKAA PMO

ANKAA PMO présent depuis plus de 20 ans sur le marché des services IT, accompagne les DSI dans leur recherche de compétences pour des besoins de renforts en mode régie ou l’externalisation de projets.
Vous souhaitez plus d’information ? Cliquez ici