This means access to the property of the class (the name of the property placed in the class), and not the instance (the property that exists for each instance of the object from this class).
Your example @@autoloadswill be saved for the length of your program.
class TestObj
@@prop = 0
def get_prop
@@prop
end
def increment_prop
@@prop += 1
end
end
a = TestObj.new
b = TestObj.new
a.increment_prop
puts b.get_prop
Codepad
source
share