From: Robert Klemme Date: 2006-11-13T04:25:08+09:00 Subject: Re: Can Ruby do this magic... elegantly Trans wrote: > J2M wrote: >> I got the final solution down to this which I think is rather elegant; >> >> class Bas < Struct.new :attribute, :another_attribute >> class << self >> attr_accessor *Bas.members >> end >> end > > class Bas < Struct.new :attribute, :another_attribute > class << self > attr_accessor *members > end > end > > Do you realize that you are adding #attribute and #another_attribute at > both the instance level and the class level, and niether will reference > tha same values? I.e. > > Bas.attribute = 1 > bas = Bas.new > bas.attribute = 2 > Bas.attribute #=> 1 > bas.attribute #=> 2 Also, what is the point in creating a Struct in this case when you're basically only using member names? robert