According to wikibooks...
@one = 1
@@value = 1
@two = 2
@one is an instance variable of the class
@@value is the class variable
@one is an instance variable it is only owned by the class
MyClass (In Ruby class is also object), not shareable, but
@@value is a shared variable.
class A @@var = 12 end class B < A def self.meth @@var end end B.meth # => 12
non shared variable
class A @var = 12 end class B < A def self.meth @var end end B.meth # => nil
@two is an instance variable of the instances of the class
Instance variables are private property of objects, thus they wouldn’t share it. In Ruby classes are also objects.
@one you defined inside a class
MyClass, thus it is only owned by that class defining it. On the other hand
@two instance variable will be created when you will be creating a object of the class
@two is only owned by
ob, none other objects have any idea about it.