Skip to content

Instantly share code, notes, and snippets.

@ncr
Created July 2, 2010 11:03
Show Gist options
  • Save ncr/461225 to your computer and use it in GitHub Desktop.
Save ncr/461225 to your computer and use it in GitHub Desktop.
irb(main):002:0> module A; def x; "x"; end end
=> nil
irb(main):003:0> module B; def x; "y"; end end
=> nil
irb(main):004:0> Class.new do include A; end.new.x
=> "x"
irb(main):005:0> Class.new do include B; end.new.x
=> "y"
irb(main):006:0> Class.new do include A; include B end.new.x
=> "y"
irb(main):007:0> Class.new do include B; include A end.new.x
=> "x"
irb(main):008:0> A.send :include, B # Look at this line.
=> A
irb(main):009:0> Class.new do include A; end.new.x
=> "x"
irb(main):010:0> Class.new do include B; end.new.x
=> "y"
irb(main):011:0> Class.new do include A; include B end.new.x # I can't find explanation for this...
=> "x"
irb(main):012:0> Class.new do include B; include A end.new.x
=> "x"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment