Locked lesson.
About this lesson
More on classes and how to use them.
Exercise files
Download this lesson’s related exercise files.
Classes Part 2.docx60.4 KB Classes Part 2 - Solution.docx
59.5 KB
Quick reference
Classes Part 2
Let's look at classes in more depth.
When to use
Classes are an essential part of object oriented programming.
Instructions
To initialize a class (start it up!) we create a new object:
my_square = Square.new(10)
Be sure to pass your parameter in!
To inspect our new object:
puts my_square.inspect
Hints & tips
- my_square = Square.new(10)
- puts my_square.inspect
Lesson notes are only available for subscribers.