From: Robert Klemme Date: 2006-02-13T05:48:15+09:00 Subject: Re: Struct creates non-standard classes 2006/2/12, Mark Volkmann :> On 2/12/06, David Vallner wrote:> > D�a Nede�a 12 Febru�r 2006 20:45 Mark Volkmann nap�sal:> > > If Struct is a shorthand way for creating Classes, why don't objects> > > created from those Classes have instance_variables? > My issue is that I wanted to think of Struct as an alternate way of> defining a class and that after doing so I could use it like any other> class. You can. > However, classes created using Struct aren't the same as> classes created in the "normal" way and because of that I have to> remember when I use them how they differ. I've found one way in which> they differ and don't know if there are others. IMHO you better get used to access instance variables through accessormethods instead of directly - even inside another class. You can runinto numerous problems if you always directly access instancevariables. The fact that Ruby allows to do this (even from sub classmethods) does not mean that it's always the best thing to do. The fact that there are instance variables is a mere detail of theimplementation. If you stick with this basic OO usage pattern and makeaccessing instance variables directly the exception instead of therule there is no difference in using Struct created classes and"normal" classes. Kind regards robert --Have a look: http://www.flickr.com/photos/fussel-foto/