From: Kent Dahl Date: 2002-08-11T05:47:09+09:00 Subject: Re: ambiguity between local variable assignment and writter method Tom Sawyer wrote: > > On Sat, 2002-08-10 at 05:26, Kent Dahl wrote: > > Tom Sawyer wrote: > > So, while not quite junk, they are ugly, nececarry implementation > > details that need to be hidden as soon as possible :-) > > how might you do that? as far i can tell that would involve declaring > variables. i don't know how i feel about that. Uh, no, I was thinking: We already use accessor methods to hide @ away, all the time from the outside, and also from the inside (which this discussion is mostly about). Earlier there has been discussions about @@ vs instance variables of the class objects. I'm not sure how cumbersome that would be to use though (in subclasses, you wouldn't be able to just do type.variable=). As for $, you use accessor methods on module (or class) objects instead, effectively giving yourself a namespace for your global variable. I.e.: module X def self.x @x end def self.x=(x) @x=x end end X.x = 5 puts X.x Defining the methods are akin to declaring the variables, but it sure beats a $�anyday :-) -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 5. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)