From: Mathieu Bouchard Date: 2001-03-21T01:57:48+09:00 Subject: [ruby-talk:12957] Re: How to add accessors dynamically? On Tue, 20 Mar 2001, Ville Mattila wrote: > Hello > I危 trying to do simple thing like this > class Foo < Module > def add_attr(name=nil,value=nil) > attr_accessor eval(":" + name) > eval("@" + name + "=" + value) > end > end instead of the eval line, try: send(name+"=", value) this should call the accessor you just created. or else you can do with eval: eval("@" + name + "=value") so that the value is picked directly from the parameters instead of being reevaluated for no particular reason. matju