From: MenTaLguY Date: 2007-06-26T01:28:46+09:00 Subject: Re: dynamically define attr_accessors on objects? On Tue, 26 Jun 2007 01:23:44 +0900, Aaron Smith wrote: > How can I dynamically define attr_accessors on an object? > > EX:;: > class Person > attr_accessor :firstname > end > p = Person.new > p.firstname = 'aaron' class << p attr_accessor :lastname end p.lastname = 'smith' > puts p.inspect > puts p.firstname > puts p.lastname You have to explicitly create the accessor methods; you don't get them automatically when setting an instance variable. -mental