Learn Ruby
Instance Method
20.4
Lesson

Instance method only work on instances

Here is our code from the previous lesson.

As we can see we are calling the method eat and gift on the instance.

Let’s try to call these methods on the class itself. We will get an error. Let’s see it in action.

We got error because the method exists only on the instances and not on the class. These methods are also called instance methods because these methods can only be called by an instance and not by the class.