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.