May 29th, 2008
Ruby doesn’t have meta classes
OK. It’s time to get rid of this terminology problem. Ruby does NOT have meta classes. You can define them yourself, but it’s not the same thing as what is commonly called the meta class. That is more correctly called the eigen class. The singleton class is also better than meta class, but eigen class is definitely the most correct term.
So what is a meta class then? Well, it’s a class that defines the behavior of other classes. You can define meta classes in Ruby if you want too by defining a subclass of Class. Those classes would be metaclasses.
Edit: Of course, if you actually try to define a subclass of Class you will find that Ruby doesn’t allow you to do that, which means that you don’t have any meta classes in Ruby. Period.