Skip to content

Instantly share code, notes, and snippets.

@lachie
Forked from benschwarz/super.rb
Created April 25, 2009 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lachie/101523 to your computer and use it in GitHub Desktop.
Save lachie/101523 to your computer and use it in GitHub Desktop.
class A
def initialize(foo)
dispatch if respond_to? :dispatch
end
end
class B < A
def dispatch
puts "called dispatch"
end
end
B.new(:moo)
# respond_to? :dispatch returns true for B
# Dispatch is never called.
# I want multiple implementations of A subclasses to automagically call dispatch
# after init. THoughts?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment