From: Ruby Newbee Date: 2009-12-15T18:41:29+09:00 Subject: Re: does module have instance_methods? 2009/12/15 Jesús Gabriel y Galán : > On Tue, Dec 15, 2009 at 5:25 AM, 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] > > It has instance_methods because those methods will be called on an > instance. It will not be an instance of that module, but it will be an > object (an instance of some class). They are very similar to the > instance_methods in a class, in the sense that an object at some point > will have this module or class in the lookup path when you call a > method on that instance, so that's the way an instance_method can be > called. Look: > Thanks Jesus, that has make things be clear.