Skip to content

Instantly share code, notes, and snippets.

@alloy
Created July 23, 2014 11:14
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 alloy/82f2f3583ddded575651 to your computer and use it in GitHub Desktop.
Save alloy/82f2f3583ddded575651 to your computer and use it in GitHub Desktop.
~/C/R/S/InteractiveRubyMotion [master] » irb
irb(main):001:0> class A
irb(main):002:1> def foo
irb(main):003:2> "A"
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> class B < A
irb(main):007:1> def foo
irb(main):008:2> super + "B"
irb(main):009:2> end
irb(main):010:1> end
=> nil
irb(main):011:0> module C
irb(main):012:1> def foo
irb(main):013:2> super + "C"
irb(main):014:2> end
irb(main):015:1> end
=> nil
irb(main):016:0> o = B.new
=> #<B:0x007f8241d52738>
irb(main):017:0> o.foo
=> "AB"
irb(main):018:0> class B
irb(main):019:1> include C
irb(main):020:1> end
=> B
irb(main):021:0> o.foo
=> "ACB"
irb(main):022:0> B.ancestors
=> [B, C, A, Object, Kernel, BasicObject]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment