Instance Variables and Methods
Understand how objects store data and interact with methods inside a class.
1
Instance Variables and Methods
Instance variables store object-specific data, and instance methods allow objects to interact with their data.
In this lesson, you will learn how instance variables and methods work in Ruby classes.

2
What are Instance Variables?
Instance variables store data specific to an object and start with @.
class Person
def initialize(name)
@name = name
end
end
person1 = Person.new('Alice')All lessons in this course
- Classes and Objects
- Instance Variables and Methods
- Inheritance and Polymorphism
- Mixins and Modules