From: ts Date: 2001-03-20T21:30:49+09:00 Subject: [ruby-talk:12936] Re: How to add accessors dynamically? >>>>> "V" == Ville Mattila writes: V> eval("@" + name + "=" + value) This is expanded to eval "@name = baz" this is why it give an error message, you want probably something like this eval "@#{name} = #{value.inspect}" but it will not work in some case, i.e. when #inspect give something like this pigeon% ruby -e 'p Object.new.inspect' "#" pigeon% V> end V> end V> f = Foo.new V> f.add_attr("bar", "baz") You can just write class << f attr_accessor :bar end f.bar = "baz" Guy Decoux