From: Lorenzo Brito Morales Date: 2011-01-24T15:25:41+09:00 Subject: Re: class_eval WOW thanks a lot, i really got crazy about that. i will continue to reading the book but as i see it, ruby really difers from other languate, his feautures are powerfull if we can understand it. On Mon, Jan 24, 2011 at 12:20 AM, botp wrote: > On Mon, Jan 24, 2011 at 1:46 PM, Lorenzo Brito Morales > wrote: >> Ok, thanks, in that way what actually we are doing is a class method > > yes. a class method > >> not? a static called in java or csharp > > similar > >> but the thing i really feel very weird is these >> class Class >> def add_accessor(accessor_name) >> self.class_eval %Q{ >> attr_accessor :#{accessor_name} >> } >> end >> end >> class Person >> end >> person = Person.new >> Person.add_accessor :name >> but why the method added to Class works on Person as class method ? if >> it is added in Class as instance method ? > > that means, Person is an instance of class Class > > ie when you do, > >  class Person >  end > > ruby treats it as > >  Person=Class.new > > > best regards -botp > >