From: Learning Ruby Date: 2006-11-03T22:58:24+09:00 Subject: Re: Output not clear ------=_Part_21421_8118699.1162562300427 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 11/3/06, Rimantas Liubertas wrote: > > > More confusion. I thought that the statement balance = @bal - amt in the > > withdraw method is actually the set method for the @balance variable of > the > > Accounts class. Is not the set method inherited in the Savings class? > > This is true. However in the case something = some_value Ruby sees it > as assignment to local variable. In this case you want self.balance = > @bal - amt > instead of balance = @bal - amt. > > > Regards, > Rimantas > Thanks. That clarified my confusion. One more related thing that confuses me is that I thought all instance variables of a class are private to the class. Then are the private instance variables inherited by a sub-class? If yes, then in my Accounts program, there is no real need to the write the attr_accessor statement? ------=_Part_21421_8118699.1162562300427--