Skip to content

Instantly share code, notes, and snippets.

@bachue
Created December 29, 2012 03:54
Show Gist options
  • Save bachue/4404485 to your computer and use it in GitHub Desktop.
Save bachue/4404485 to your computer and use it in GitHub Desktop.
class A
def self.name; 'A'; end
def self.f; "#{name}#{superclass.f if superclass.respond_to? :f}"; end
end
class B < A
def self.name; 'B'; end
end
class C < B
def self.name; 'C'; end
end
class D < C
def self.name; 'D'; end
end
# call
# D.f
# 'DCBA'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment