Tutorial by Examples

Protocols enable polymorphism in Elixir. Define protocols with defprotocol: defprotocol Log do def log(value, opts) end Implement a protocol with defimpl: require Logger # User and Post are custom structs defimpl Log, for: User do def log(user, _opts) do Logger.info "User: ...

Page 1 of 1