Created
June 7, 2009 00:11
-
-
Save jeremy/125071 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Including a module included in a superclass is ignored | |
>> module Foo; end | |
=> nil | |
>> class Numeric; include Foo; end | |
=> Numeric | |
>> Float.ancestors | |
=> [Float, Precision, Numeric, Foo, Comparable, Object, Kernel] | |
>> class Float; include Foo; end | |
=> Float | |
>> Float.ancestors | |
=> [Float, Precision, Numeric, Foo, Comparable, Object, Kernel] | |
# But reversing the order of inclusion works as expected | |
>> module Foo; end | |
=> nil | |
>> class Float; include Foo; end | |
=> Float | |
>> Float.ancestors | |
=> [Float, Foo, Precision, Numeric, Comparable, Object, Kernel] | |
>> class Numeric; include Foo; end | |
=> Numeric | |
>> Float.ancestors | |
=> [Float, Foo, Precision, Numeric, Foo, Comparable, Object, Kernel] | |
# And so does including a dupe of the module! | |
>> module Foo; end | |
=> nil | |
>> class Numeric; include Foo; end | |
=> Numeric | |
>> Float.ancestors | |
=> [Float, Precision, Numeric, Foo, Comparable, Object, Kernel] | |
>> class Float; include Foo.dup; end | |
=> Float | |
>> Float.ancestors | |
=> [Float, #<Module:0x19bcd40>, Precision, Numeric, Foo, Comparable, Object, Kernel] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment