Possible Duplicate:
What does @@variable mean in Ruby?
What is the difference when I declare an object with double '@'
@@lexicon = Lexicon.new()
and declaring object with single '@' in Ruby?
@lexicon = Lexicon.new()
Possible Duplicate:
What does @@variable mean in Ruby?
What is the difference when I declare an object with double '@'
@@lexicon = Lexicon.new()
and declaring object with single '@' in Ruby?
@lexicon = Lexicon.new()
The difference is that the first one is a class variable and the second one is an instance variable.
An instance variable is only available to that instance of an object. i.e.
class Yasin
  def foo=(value)
    @foo = value
  end
  def foo
    @foo
  end
end
yasin = Yasin.new
yasin.foo=1
yasin.foo #=> 1
yasin_2 = Yasin.new
yasin_2.foo #> nil
A class variable is available to all instances of the class (and subclasses, iirc) where the class variable was defined.
class Yasin
  def foo=(value)
    @@foo = value
  end
  def foo
    @@foo
  end
end
yasin = Yasin.new
yasin.foo=1
yasin.foo #=> 1
yasin_2 = Yasin.new
yasin_2.foo #=> 1
