Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Created June 17, 2015 14:28
Show Gist options
  • Save mikecmpbll/35e3ff8efb5756ef8876 to your computer and use it in GitHub Desktop.
Save mikecmpbll/35e3ff8efb5756ef8876 to your computer and use it in GitHub Desktop.
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