3.6. Classes as objects and message receivers
Classes are special objects: they’re the only kind of object that has the power to spawn new objects (instances). Nonetheless, they’re objects. When you create a class, like Ticket, you can send messages to it, add methods to it, pass it around to other objects as a method argument, and generally do anything to it you would to another object.
Like other objects, classes can be created—indeed, in more than one way.
3.6.1. Creating class objects
Every class—Object, Person, Ticket—is an instance of a class called Class. As you’ve already seen, you can create a class object with the special class keyword formula:
class Ticket # your code here end
That formula is a special provision by Ruby—a way to make ...
Get The Well-Grounded Rubyist, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.