Object-Oriented Programming I
Why Classes?

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

# ==> 4

the "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 ruby, python, and javascript instances. Click Save & Submit Code to see how they work!

When you're ready, click Save & Submit Code to get started creating classes and objects of your own.


Learn more advanced Ruby in our new Ruby on Rails course!