+ 2
What is polymorphism mean?
hi, I've seen polymorphism concept, recently. but I can't understand it very well. please describe this concept for me completly. also see my projects on github and share your ideas about them. github.com/mohsen8156 thsnks.
2 ответов
+ 10
Polymorphism is a concept of a method or operator to work regardless the data type it is used with. The simplest and most common example is the 'add' operator. You can use it freely with most data types and it will act on them properly, as long as there is a logic behind it.
So for example, you can add integers to floats and to complex numbers - all that will work even though they are actually of different types.
On the other hand, you can add strings with chars or string slices - it will concatenate them.
All this is possible because the same operator has different implementations for each data type. This particular feature makes it polymorphic.
+ 1
ask Google