the.com/polymorphism
One name, many bodies — the function doesn't care what you are, just that you can act.
means The ability for something — a function, a method, an interface — to take different forms or behave differently depending on the type of data it's acting on, while keeping the same name or signature.
from From Greek 'poly' (many) and 'morphē' (form, shape) — the same roots that give us 'amorphous' and 'metamorphosis.' Biologists used 'polymorphism' first, for species that occur in several distinct physical forms (think ants with different castes, or butterflies with multiple wing patterns). Computer science borrowed the word in the mid-20th century to describe code that likewise wears different shapes depending on context — one call, many possible bodies underneath.
- literal meaning
- Greek for many shapes, same soul
- compile time
- overloading picks the form before running
- runtime version
- overriding decides the form while running
- real power
- lets code call methods it never met