Introduction to Objects and Classes in Ruby
Learn about classes and objects in Ruby.
We'll cover the following
Introduction
Ruby is an object-oriented programming language. Object-oriented programming is centered around the idea of classes and objects. Let’s look at an example to understand what we mean by classes and objects.
Example
In our example, Car
is a class, a user-defined type. It has the following two functions (plus many more):
accelerate
brake
In this class, my_car
and your_camry
are two different objects. They can brake
, accelerate
, and drive physically.
Get hands-on with 1200+ tech skills courses.