Wednesday, June 14, 2017

Benefits of using objects

The  benefit of using objects is that they keep a set  of data,and the methods that operate on that data, in one place

An instance of  a class is an object that was made using the class.You only have to write one class,but you can make many instances of that class.

Think of “instance” as another way of saying “object”

Instance variables  are variables that belong to one object.They comprise everything the object knows about itself.They represent the object’s state (its data) and they can have different values for each instance of the class.

What’s the difference between a class and an object?

A class is a blueprint for an object.The class tells Ruby  how to make an object of that particular type.Objects have the instances varibles  and instance methods,but those variables and methods are designed as part of the class.

No comments:

Post a Comment