From: Chris Morris Date: 2002-10-15T02:39:26+09:00 Subject: Re: Referring to instance vars in a Struct? > Is there any reason why you don't want > to create a TestMe class instead of a TestMe struct? Probably just the > amount of typing? Or for efficiency reason, do you think? In my real code, I had a struct that represented a database row with several fields. I know it's not much more work (esp. with a good editor) to go from this: MyClass = Struct.new('MyClass', :field1, :field2, ..., :fieldx) to this: class MyClass attr_accessor :field1, :field2, ..., :fieldx def initialize(field1, field2, ..., fieldx) @field1 = field1 @field2 = field2 ... @fieldx = fieldx end end ...but it is a bit more work. But the point for me is still the surprise of not having an instance var inside a Struct (although it does make sense that this is probably pushing Structs beyond their intended use). Chris