From: Steven Smolinski Date: 2003-02-07T13:36:03+09:00 Subject: Re: Private lvalue methods unusable? Dmitri Colebatch wrote: >> In message "Private lvalue methods unusable?" >> on 03/02/07, Steven Smolinski writes: >> >> |How do I call a private lvalue method? >> >> No way, except using "send", e.g. >> >> self.send(:dollars=, 100) > > I'm assuming there's some good reason for this that isn't apparent to > (at least) me. Would someone care to enlighten me out of interest? Private methods can't have an explicit receiver (i.e., you can't do self.method on a private). Calling it directly looks like this: dollars = 100 So a private lvalue method and assignment to a local variable have the exact same syntax. Which means ruby had to choose whether it should: 1) look for a method and raise an exception if there is none, or 2) create a local variable. It appears ruby does (2). I suppose there's always (3), which is to look for a method first and create a local variable if there's no method defined. But that's some serious semantic gymnastics, and may make things worse rather than better. I don't know enough about ruby to comment on that. 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