Created
March 18, 2010 01:51
-
-
Save jmeridth/335962 to your computer and use it in GitHub Desktop.
ruby object model class variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@test = 20 | |
class A | |
@@a = 1 | |
def self.a | |
@@a | |
end | |
def hello | |
puts "hello from A" | |
end | |
end | |
class B < A | |
@@a = 22 | |
def hello | |
puts "hello from B" | |
end | |
end | |
puts @@test | |
a = A.new | |
a.hello | |
puts A.a | |
b = B.new | |
b.hello | |
puts B.a | |
~ > ruby test.rb | |
20 | |
hello from A | |
22 | |
hello from B | |
22 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment