Elixir Language Polymorphism in Elixir


Polymorphism is the provision of a single interface to entities of different types. Basically, it allows different data types respond to the same function. So, the same function shapes for different data types to accomplish the same behavior. Elixir language has protocols to implement polymorphism with a clean way.


If you want to cover all data types you can define an implementation for Any data type. Lastly, if you have time, check the source code of Enum and String.Char, which are good examples of polymorphism in core Elixir.