Created
June 17, 2015 14:28
-
-
Save mikecmpbll/35e3ff8efb5756ef8876 to your computer and use it in GitHub Desktop.
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
class SC | |
def self.set_var(val) | |
@var = val | |
end | |
def superclass_instance_get_var | |
puts self.class.instance_variable_get("@var") | |
end | |
def self.superclass_class_get_var | |
puts instance_variable_get("@var") | |
end | |
end | |
class C < SC | |
set_var "foo" | |
def subclass_instance_get_var | |
puts self.class.instance_variable_get("@var") | |
end | |
def self.subclass_class_get_var | |
puts instance_variable_get("@var") | |
end | |
end | |
C.new.subclass_instance_variable_get | |
C.subclass_class_get_var | |
C.new.superclass_instance_get_var | |
C.superclass_class_get_var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment