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
> 
> Thanks in advance.


irb(main):004:0> class Global
irb(main):005:1> module TestMod
irb(main):006:2> TEST = "test1"
irb(main):007:2> def print_test
irb(main):008:3> puts "test2"
irb(main):009:3> end
irb(main):010:2> end
irb(main):011:1> extend TestMod
irb(main):012:1> end
=> Global
irb(main):013:0> Global.print_test
test2
=> nil

ilan


-- 
Posted via http://www.ruby-forum.com/.