On Friday, February 7, 2003, 10:35:08 AM, Steven wrote:

> Let's say I have a class with a private method, say:

>   private
>   def dollars=(someDollars)
>     @cents = someDollars * 100
>   end

> And if I want to use this method from some other method in the class, I
> always create a local variable instead.  I can't prepend the method name
> with a receiver ("self") because the method is private.

> For exmaple, this assigns to a local variable instead of using the
> private method above:

>   public
>   def fillWallet
>     dollars = 100
>     puts "Wow!  You've got $" + dollars().to_s
>   end

> How do I call a private lvalue method?


Hmmm.... so self.dollars = 100 doesn't work, eh?  Only answer I can
think of is

   self.send(:dollars=, 100)

Beautiful, isn't it? ;)

Actually, a better answer came to mind.  Make :dollars= protected
instead of private.  It works.

Gavin