From: "David A. Black" Date: 2008-03-26T20:26:50+09:00 Subject: Re: class_eval vs (class << object) Hi -- On Wed, 26 Mar 2008, Ruby Freak wrote: > What is the difference between class_eval and "class << object"? > > It seems like they are the same. I am thinking that class_eval affects > the greater class and "class_object" is used on a singleton class. Are > they mutually exclusive? class << object is the class keyword, which starts a class definition block (in this case, on the singleton class of object) and therefore a new local scope. class_eval is a method, not a keyword, so it requires a receiver -- namely, a Module or Class object. It takes a block, and the block does shares the variables of the existing local scope. David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!