Ruby is an object-oriented programming language, which means it manipulates programming constructs called objects. (Almost) everything in Ruby is an object! You’ve been using them all along, so they should be very familiar. Objects have methods, which you’ve seen before, and attributes, which are just data. For instance, in
"Matz".length # ==> 4
"Matz" object is a string with a
.length method and a length attribute of
4. We’ll learn how to build our own objects with their own methods and internal variables in the next few exercises.
But what exactly makes
"Matz" a string? The fact that it’s an instance of the
String class. A class is just a way of organizing and producing objects with similar attributes and methods.
Check out the code in the editor to the right. We’ve defined our own class,
Language, and created
Move on when you’re ready to get started creating classes and objects of your own.