In this blog post I’ll explain what polymorphism is. Let’s start with a definition:
Polymorphism is an ability to have a variable or value that can have many different types.
Languages that provide this ability are called polymorphic languages. Function which operands (values of its parameters) can have many different types is called polymorphic function.
Type in definitions above is defined as a set of values. Saying that value x has a type X means that value x belongs to the type X.
Types in programming languages also often have corresponding interfaces that describe what operations particular type provides. If a variable or value is polymorphic (can have different types), then those types should share a common structure (interface), so the code that operates on it is identical regardless of what is the actual type of this variable or value.