x = 1 + 2
Here + is a method of the Fixnum (Integer) object, 1. The value 2 is sent to this method; the result, 3, is returned and this is assigned to the object, x. Inciden-tally, the operator, =, is one of the rare exceptions to the rule that ‚everything you do with an object is done by a method‛. The assignment operator is a special built-in ‘thingummy’ (this is not the formal terminology, I hasten to add) and it is not a method of anything.
Now let’s see how to create objects of our own. As in most other OOP languages, a Ruby object is defined by a class. The class is like a blueprint from which individual objects are constructed. For example, this class defines a dog: