A variable is a name Ruby uses to identify a specific object. For instance, "Toronto" is a city. The string "Toronto" is associated with the name (variable) city in this case. Consider it as if Ruby were to create two tables. One has items, whereas the other has names for them.
There are four types of variables in Ruby:
Local ,Class, Instance, and Global
@title is a class-wide instance variable that is accessible to all methods. Declaring variables in your controller as instance variables (@title) in Ruby on Rails makes them available to your view.
Variables in Ruby are storage locations for data that will be used in programmes. Each variable is given a unique name. The names of these variables are based on naming conventions. In contrast to other programming languages, Ruby does not need the declaration of variables.
The assignment statement is written in the form of: "variable=value". For example, if you want to change the value of x to 5, your assignment statement would be "x=5".