From: Yukihiro Matsumoto Date: 2005-05-21T12:06:11+09:00 Subject: Re: Anonymous module undefined method error Hi, In message "Re: Anonymous module undefined method error" on Sat, 21 May 2005 06:45:15 +0900, "johng" writes: |I am new to Ruby so please excuse my question. I did search |usenet for an answer but couldn't find one: | |I have a variable, data, that was read from a file and has the |following contents: | |def foo | return "foo" |end | |My code is this: | |amodule = Module.new |amodule.class_eval(data) | |puts(amodule.public_instance_methods) -> outputs "foo" | |amodule.foo -> fails saying method is undefined A public *instance* method means methods are available for their instances, "amodule" is a module, not an instance. When you include a module to a class, and instantiate from the class, you can call "foo". matz.