A class is a piece of code within a program that functions as a template or blueprint for creating mulitple instances of a particular object.

The template provides initial values and behavior for each of these instances. Each instance is an object itself.


Suppose we want to create a Cat class with three instance variables:

  • @cat_name
  • @cat_color
  • @cat_age

Now we can create a bunch of objects based off of the Cat class:

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn More on Codecademy