O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Protocols Are Polymorphism

When you want to write a function that behaves differently depending on the type of its arguments, you’re looking at a polymorphic function. Elixir protocols give you a tidy and controlled way to implement this. Whether you’re integrating your types into the existing Elixir library or creating a new library with a flexible interface, protocols let you package the behaviour in a well-documented and disciplined way.

And with that, we’re almost done. But when you write about a language, there are always little details that don’t seem to fit anywhere. That’s why the next chapter is full of odds and ends.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required