Elixir Language Polymorphism in Elixir

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

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.

Remarks

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.



Got any Elixir Language Question?