On Thu, 31 May 2001, Hal E. Fulton wrote:

> What about an include as you showed it, outside of a class definition?
> Well, it becomes part of Object. (Remember that Object is a class.) So,
> unless I'm grossly mistaken, if you "include Wombat" at the top level,
> every object x created from then on would give true for x.is_a? Wombat,
> whether it's an array, a string, a class, or whatever. 



actually, all Objects created, ever, irrevocably become Wombats. In theory
the inheritance in Ruby objects don't depend on when they are created.



But I have just found a case where it actually matters. Here it is:

module A; end
module B; include A; end
module C; include A; end
[A,B,C].each{|k| k.module_eval "def foo; '#{k}' + super; end" }
module Kernel; def foo; "" end end
x = Object.new; x.extend C; p x.foo
include B; p x.foo
x = Object.new; x.extend C; p x.foo

This prints:
	"CA"
	"CABA"   # A is seen twice in old x
	"CBA"    # A is seen once  in new x



Funny, eh?

matju