Locked lesson.
About this lesson
What is an instance variable and how is it different from a regular variable?
Exercise files
Download this lesson’s related exercise files.
Instance Variables.docx60.4 KB Instance Variables - Solution.docx
60.7 KB
Quick reference
Instance Variables
Let's look at instance variables.
When to use
Instance variables are used inside your class and can be used in any method within your class.
Instructions
An instance variable starts with an @ sign. For instance:
@side_length
Hints & tips
- Instance variables start with an @ sign
- They can be used in all your class methods
Lesson notes are only available for subscribers.