From: Phrogz Date: 2006-10-17T22:15:06+09:00 Subject: Re: dynamically assigning instance variables (redux) Ryan Davis wrote: > class Foo > def initialize( hash={} ) > hash.each do |ivar, val| > self.class.send :attr_accessor, ivar unless respond_to? ivar > send "#{ivar}=", val > end > end > end This is distinctly different, however, in that it adds the accessor methods to the Foo class, not the instances. I have no idea what Mr. Kleb wanted, but given that he's adding accessors based on hashes passed to each instance, my guess was that he would want a unique set per instance. f1 = Foo.new :name=>'whee' f2 = Foo.new :age=>12 p f1.age #=> nil Is the above result desirable, Bill?