On 6/23/07, Trans <transfire / gmail.com> 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?
>
> T.
>
>
Just reinclude Enumerable, well that seems to be the simplest way to
achieve what you wanted:
>
510/10 > irb
irb(main):001:0> module A; def x; 42 end end
=> nil
irb(main):002:0> module Enumerable; include A end
=> Enumerable
irb(main):003:0> class Array; include Enumerable end
=> Array
irb(main):004:0> [].x
=> 42

And yes it works outside irb too.

Robert
-- 
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw