I don't think there is a distinct difference between class variable and instance variable. The class variable can also be seen as an instance variable. Am I right?
For example:
class Test
@class_var = 'hello world'
def self.show_class_var
@class_var
end
def show_class_var
puts self.class.show_class_var
end
end
So, I figure we can treat a class variable as the instance variable of the current class (Test
). If we define @@class_var = 'hello world'
, the only benefit is that we can directly refer @@class_var
in the instance method. I just want to know if I am right. Am I?