From: Rick DeNatale Date: 2007-06-24T05:33:37+09:00 Subject: Re: Can't include a module in Enumerable? On 6/23/07, Trans wrote: > irb(main):002:1> module Z > irb(main):003:1> def x; "x"; end > irb(main):004:1> end > => nil > irb(main):005:0> module Enumerable > irb(main):006:1> include Z > irb(main):007:1> end > => Enumerable > irb(main):008:0> a = [1,2,3,4,5] > => [1, 2, 3, 4, 5] > irb(main):009:0> a.x > NoMethodError: undefined method `x' for [1, 2, 3, 4, 5]:Array > from (irb):9 > from :0 > > Is the Double Inclusion Problem worse than I realized? I thought the > above would be okay b/c 'a' is instantiated _after_ the inclusion > (which is why I've often called it the Dynamic Inclusion Problem). > What gives? It's not the instance, it's the class Array, and that existed (and included Enumerable) before you changed Enumerable. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/