I see that Ruby has the following variables:
– global variables (represented by $variable_name)
– class variables (represented by @@variable_name)
– instance variables (represented by @variable_name) and
– local variables (represented by variable_name or _variable_name)
Occasionally I see the following in the rails source code:
class SomeClass
@var
end
Here what exactly @var represent and what do you call it, metaclass variable?
Also whats the advantage of using this kind of variables?
It is one of the classes instance variables. In Ruby, everything is an object, even classes, so it isn’t surprising that classes can have instance variables.
More Info