Skip to content

Instantly share code, notes, and snippets.

@jeremyf

jeremyf/super.rb

Created Apr 13, 2017
Embed
What would you like to do?
Super method definition
module A
def hello
puts 'hello'
end
end
module B
def hello
puts 'potato'
super
end
end
class C
include A
include B
def hello
super
puts "something"
end
end
c = C.new
c.hello
# Find the hello instance method for the C class
C.instance_method(:hello).source_location
# Find the definition of super for the hello instance method for the C class
C.instance_method(:hello).super_method.source_location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.