From: Brian Candler Date: 2007-04-03T06:29:55+09:00 Subject: Re: Nested Modules/Classes On Tue, Apr 03, 2007 at 06:02:41AM +0900, Ken Mitchell wrote: > I have what I feel should be a simple issue. Look at the following: > > ############################ > # Test of nested modules/classes > ############################ > class Global > module TestMod > TEST = "test1" > def print_test > puts "test2" > end > end#module TestMod > > include TestMod > puts TEST > print_test > > end#class Global > ############################## > > ->test1 > ->test.rb:22: undefined local variable or method 'print_test' for > Global:Class > > Whether "Global" is a Class or a Method the same happens. However, if I > comment out "Global" completely, out put is as expected: > > ->test1 > ->test2 If you 'include' a module in a class, its methods are added as instance methods for objects of that class. Try: a = Global.new a.print_test