From: Gary Wright Date: 2009-12-15T13:54:36+09:00 Subject: Re: does module have instance_methods? On Dec 14, 2009, at 11:25 PM, Ruby Newbee wrote: > I'm still confused, since module can't be instantiated, why it has the > instance methods? > > irb(main):162:0> module Mymod > irb(main):163:1> def myway;end > irb(main):164:1> end > => nil > irb(main):165:0> Mymod.respond_to? :myway > => false > irb(main):166:0> Mymod.instance_methods > => [:myway] You can think of a module as a container for method definitions. By storing the definitions in a module you can reuse the methods without having to duplicate code by 'including' the module in a class or even another module: module A def a1; "method a1"; end def a2; "method a2"; end end class B include A end B.new.a1 B.new.a2 class C include A end C.new.a1 C.new.a2 # You can even next modules within modules: module D include A end class E include D end E.new.a1