Course Content

Course Content


Instance variables are a part of the object's state that is unique to each instance. Class variables are shared between all instances of the same class.

Variables are a way to store data and reuse it in your program. Variables are created using the keyword "var" followed by a name for the variable.

In Ruby, an instance variable has a name that begins with the @ symbol, and its content is limited to whatever the object refers to. Even if they belong to the same class, two independent objects can have different values for their instance variables.

The @ symbol before a variable indicates that we're dealing with an instance variable, while the @@ symbol indicates that we're dealing with a class variable. In instance methods within a class, we use @ before a variable to instruct Ruby to access that attribute (instance variable) of the instance.

An instance variable is a type of variable in the Ruby programming language that begins with the @ symbol. @fruit is a good example. In Object-Oriented Programming (OOP), an instance variable is used to offer objects their own private place to store data.

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere