Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created May 28, 2009 20:14
Show Gist options
  • Select an option

  • Save ashgti/119538 to your computer and use it in GitHub Desktop.

Select an option

Save ashgti/119538 to your computer and use it in GitHub Desktop.
class TestClass
@@var = "a class variable"
@var = "a class instance variable"
def self.print
puts @@var
puts @var
end
end
class DerivedTestClass < TestClass
def self.set_var
@@var = "a class variable : changed"
@var = "a class instance variable : changed"
end
end
TestClass.print
puts "-------------"
DerivedTestClass.print
puts "-------------"
DerivedTestClass.set_var
DerivedTestClass.print
puts "-------------"
TestClass.print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment