The real world is filled by objects, and we can classify them. For example, a very small child is likely to say "bow-wow" when seeing a dog, regardless of the breed; we naturally see the world in terms of these categories.
In OO programming terminology, a category of objects like "dog" is called a class, and some specific object belonging to a class is called an instance of that class.
Generally, to make an object in ruby or any other OO language,
first one defines the characteristics of a class, then creates an
instance. To illustrate the process, let's first define a simple
In ruby, a class definition is a region of code between the keywords
Now that we have defined a
We have made a new instance of the class
Making a new instance of a class is sometimes called instantiating that class. We need to have a dog before we can experience the pleasure of its conversation; we can't merely ask the Dog class to bark for us.
It makes no more sense than trying to eat the concept of a sandwich.
On the other hand, if we want to hear the sound of a dog without getting emotionally attached, we can create (instantiate) an ephemeral, temporary dog, and coax a little noise out of it before it disappears.
"Wait," you say, "what's all this about the poor fellow
disappearing afterwards?" It's true: if we don't bother to give
it a name (as we did for