From: Trans Date: 2005-04-18T09:04:33+09:00 Subject: Re: self Robert Klemme wrote: > Btw, I would find something like this useful in the std lib: > > class Class > def properties(*h) > h = h[0] if h.size == 1 > initial = {} > > h.each do |name, val| > attr_accessor name > initial[name]=val unless val.nil? > end > > unless initial.empty? > alias :new_plain :new > class< define_method(:new) do |*a| > obj = allocate > initial.each {|name, val| obj.send("#{name}=".to_sym, val)} > obj.instance_eval { initialize(*a) } > obj > end > end > end > > h > end > end Ubfortunately, I think it is a bit dangerous to mess with #new like this as a standard practice. Yet I do not see any other way to set the instance vars. Agree or no? T.