Hi -- On Tue, 9 May 2006, Logan Capaldo wrote: > > On May 8, 2006, at 4:10 PM, dblack / wobblini.net wrote: > >> I can't help feeling it's a lot of trouble to do this: >> >> class C >> def initialize >> self.container = [] >> end >> >> private >> attr_writer :container >> end >> >> rather than: >> >> class C >> def initialize >> @container = [] >> end >> end >> >> if you're just using @container as a state variable here and there. >> >> I think the role of the uniform access principle here is open to >> question. As I understand it, that principle states that the outside >> user shouldn't be able to tell whether a value is stored or calculated >> -- essentially, an attribute vs. the return value of a method call. >> But instance variables are neither attributes nor methods; so they're >> not really candidates for being evaluated for uniform/non-uniform >> access. And Ruby's attributes *are* methods. To that extent, Ruby >> actually enforces the UA principle; when you do this: >> >> obj.something >> >> you know that you've called a method. There's no other possibility, >> so there's no opportunity for divergence of the interface. > > Well at least if you do it my way, you don't get tripped up by typos, ;) Why not? :-) class C def initialize self.contanier = [] end private attr_writer :container end That will blow up just as much as: class C def initialize @contanier = [] end def insert(x) @container << x end end (It will happen at a slightly different point, of course.) David -- David A. Black (dblack / wobblini.net) * Ruby Power and Light, LLC (http://www.rubypowerandlight.com) > Ruby and Rails consultancy and training * Author of "Ruby for Rails" from Manning Publications! > http://www.manning.com/black