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
Object-Oriented Programming II

Quick Review: Building a Class

Let's build a class!

class ClassName def method_name(parameter) @class_Variable = parameter end end
  1. First we tell Ruby that we want to construct our class ClassName. Don't forget the end to end your class!
  2. Inside our ClassName is where we define our methods. Here we have MethodName followed by (parameter), When we use this method it will look like this MethodName("hello!")
  3. If our parameter above were "Hello!" it would be assigned to our variable @classVariable on the following line.
  4. Again, don't forget to end your MethodName!
Report a Bug
If you see a bug or any other issue with this page, please report it here.