February 2018
Beginner
200 pages
4h 37m
English
Elixir’s protocol is a feature that lets you create a single interface that various data types can implement. Using that, you can have polymorphism: a single interface that works with different data types. If you came from object-oriented languages like Java, you’ll see that it’s very similar to how interfaces work. Elixir protocols will help you create simple interfaces, leading to a better codebase design.
In this section we’ll explore more about structs, including structs that reference other structs. We’ll refactor our code to create a reusable module that shares functions between heroes and action selections. Then we’ll build polymorphic functions with protocols to display heroes and actions. ...
Read now
Unlock full access