From: Brian Buckley Date: 2007-02-20T10:59:51+09:00 Subject: Re: include Module in another Module Thanks, Pit. Rounding this out, I notice now that classes that "include Enumerable" after Enumerable is enhanced by "include Foo" have the extra method, but classes that "include Enumerable" before Enumerable is enhanced don't (core class Array is in this category). Interesting to learn this behavior is considered a bug, and may one day be fixed. Interestingly, re-including Enumerable to Array, i.e., the line class Array; include Enumerable end corrects the bug for Array --- this is not necessarily a useful thing to know since as you suggest putting code directly into Enumerable rather than by using an include appears to be the way to go here. --Brian On 2/19/07, Pit Capitain wrote: > Brian Buckley schrieb: > > What is the proper syntax/code to include a Module into another > > Module? My attempt below is not working. > > > > module Foo > > def xxx; "this is xxx" end > > end > > > > module Enumerable > > include Foo > > end > > > > puts [].xxx #does not work, xxx not defined for Array. Array > > includes Enumerable, right? > > Brian, this isn't a problem of your syntax/code, but a (well known) > problem of the Ruby interpreter. There's no known solution yet. You have > to change the Enumerable module directly. > > Regards, > Pit > >