Search code examples
rubyinstance-variablesclass-variables

Difference Between @ and @@ instance


I produce an app with ruby, and benefited from ruby tutorials. So, I meet this syntax (@@vars), and want to ask it. (I think it's like a pointer in C or two dimensional array)

@@vars AND @vars


Solution

  • @var is an instance variable, whereas @@var is a class variable. See for example:

    http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/