From: Gavin Sinclair Date: 2002-11-10T22:45:29+09:00 Subject: Re: Making Instace Variables Private/Local From: "William Djaja Tjokroaminata" > Gavin Sinclair wrote: > > If C++ and Java allow derived classes to access parent's instance variables, > > then why not Ruby? Granted, at least in these languages, instance variables > > can be made genuinely private, but I don't think it would make sense for Ruby > > to make *all* instance variables private. > > Hi Gavin, > > But remember, C++ and Java are *statically typed* languages. I can just > check the one and only one place of variable declarations and I know all > the instance variables. Not so with Ruby; it is fundamentally difficult > to know whether I accidentaly overwrite someone else's variable with the > same name; only bugs will reveal that... :) > > Bill Good point. For this general reason, I usually endeavour to enumerate my instance variables somewhere near the top of the class definition. Nothing hard and fast - just something to remind me what I'm using, even if it's just initialising then in the constructor. Gavin