Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Learn
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

"Matz".length # ==> 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.

Instructions

Check out the code in the editor to the right. We've defined our own class, Language, and created ruby, python, and javascript instances. Run the code to see how they work!

Move on when you're ready to get started creating classes and objects of your own.

Report a Bug
If you see a bug or any other issue with this page, please report it here.