Inspect

Learn the Inspect built-in protocol in Elixir.

Introduction

This is the protocol that’s used to inspect a value. The rule is simple. If we can return a representation that’s a valid Elixir literal, do so. Otherwise, prefix the representation with #Typename.

We could just delegate the inspect function to the Elixir default. That’s what we’ve been doing so far. But we can do better. Not surprisingly, we do that by implementing the Inspect protocol. We’ll do it for both the overall Midi type and for the individual Midi.Frames.

Get hands-on with 1200+ tech skills courses.