Skip to content

Instantly share code, notes, and snippets.

@banister

banister/o.rb Secret

Created September 3, 2015 23:51
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 banister/31c6353724a076bfcc51 to your computer and use it in GitHub Desktop.
Save banister/31c6353724a076bfcc51 to your computer and use it in GitHub Desktop.
[1] pry(main)> class A
[1] pry(main)* def x
[1] pry(main)* puts "from A"
[1] pry(main)* end
[1] pry(main)* end
=> :x
[2] pry(main)> class B < A
[2] pry(main)* def x
[2] pry(main)* puts "from B"
[2] pry(main)* end
[2] pry(main)* end
=> :x
[3] pry(main)> class C < B
[3] pry(main)* def x
[3] pry(main)* puts "from C"
[3] pry(main)* end
[3] pry(main)* end
=> :x
[4] pry(main)> C.new.x
from C
=> nil
[5] pry(main)> C.new.method(:x).super_method.call
from B
=> nil
[6] pry(main)> C.new.method(:x).super_method.super_method.call
from A
=> nil
[7] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment