I'm learning Ruby, and trying to grasp the non-declarative concept with
some small difficulties. Specifically, I can't use a private lvalue
method the way I want. Please excuse me if this is a FAQ, but I
couldn't find it.
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?
Steve
--
Steven Smolinski => http://arbiter.ca/
GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
=> or email me with 'auto-key' in the subject.
Key Fingerprint => 08C8 6481 3A7B 2A1C 7C26 A5FC 1A1B 66AB F637 495D