From: Gavin Sinclair Date: 2002-08-13T23:40:01+09:00 Subject: Re: ambiguity between local variable assignment and writter method Very nice analogy! And good example, too. ----- Original Message ----- From: "Massimiliano Mirra" > [On calling setter from inside the class] > > > Consider this: > > > class HalfDouble > attr_reader :double, :half > > def double=(val) > @double = val > @half = @double / 2 > end > > def half=(val) > @half = val > @double = @half / 2 > end > end > > hd = HalfDouble.new > > hd.double = 4 > > p hd.half > p hd.double > > > Then try to replace @double= with self.double= and @half= with > self.half= and see what happens... > > > Maybe I'm just being naive, but even though a one uses tongue to > translate his thought for the outside world, and ears to translate > what comes from the outside world into thought, I see nothing wrong in > using just thought for internal communication. > > In other words, to me, using setters from inside the class seems a lot > like talking to oneself. :-) > > > Massimiliano