Built-in Protocols
Understand built-in protocols in Elixir.
We'll cover the following
Introduction
Elixir comes with the following protocols:
Enumerable
Collectable
Inspect
List.Chars
String.Chars
To play with these, let’s work with MIDI files for the next few lessons.
Example
A MIDI file consists of a sequence of variable-length frames.
Each frame contains a four-character type, a 32-bit length, and then length
bytes of data.
We’ll define a module that represents the MIDI file content as a struct because the struct lets us use it with protocols. The file also defines a submodule for the individual frame structure.
Get hands-on with 1400+ tech skills courses.