Diving into Ruby Singleton Classes

Léonard Hetsch
7 min readJul 12, 2019

One of the most mysterious aspects of the Ruby object model is the existence of singleton classes. Maybe you also read about metaclasses or eigenclasses, they are actually all referring to the same thing. Still, the “official” name being singleton classes, I will use this term through this post.

You actually don’t need to understand much of singleton classes (or to even know they exist at all) to write decent and useful Ruby code. Though, as they form an essential part of the Ruby object model, it is always an interesting — and sometimes powerful — knowledge to have.

--

--

Léonard Hetsch

Software engineer based in London / Technical coach @makersacademy / Previously @stuart @dicefm & @oncetheapp / Studied @gobelins_paris / Hungry learner.