What is polymorphism mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.

14th Sep 2017, 6:36 AM
mohsen
2 Answers
+ 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.
14th Sep 2017, 6:45 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
ask Google
14th Sep 2017, 6:37 AM
Ronald
Ronald - avatar