From: Drew Olson Date: 2008-03-08T06:21:02+09:00 Subject: Re: instance_eval and class_eval - names got mixed up? Bharat Ruparel wrote: > Thanks gentlemen for your responses. It still requires mental gyrations > for me. I honestly think that this one got away from Matz. The confusion here is that you're calling instance eval on a specific class. In ruby, classes are instances of the Class class (no, that is not a type). Methods added to your class (the instance of the class Class) are, in effect, added the the class definition. Below is an example of using class_eval and instance_eval against a simple class, so you might find this less confusing. >> class Foo >> def hi >> puts "hi" >> end >> end => nil >> foo = Foo.new => # >> foo.instance_eval do ?> hi >> end hi => nil >> Foo.class_eval do ?> def howdy >> puts "howdy" >> end >> end => nil >> foo.howdy howdy => nil -- Posted via http://www.ruby-forum.com/.