From: "Hal E. Fulton" Date: 2003-03-21T18:14:56+09:00 Subject: Re: Proposal: new operator: '<-' (for assignments) ----- Original Message ----- From: "Phil Tomson" Newsgroups: comp.lang.ruby To: "ruby-talk ML" Sent: Friday, March 21, 2003 2:41 AM Subject: Re: Proposal: new operator: '<-' (for assignments) > In article <2003320223415.480988@PADD>, > Austin Ziegler wrote: > >On Fri, 21 Mar 2003 11:20:27 +0900, Phil Tomson wrote: > >> Now of course, I could have allowed access to @val by declaring an > >> attr_accessor, but in many cases I don't want to expose that > >> information or make users of the class have to remember the name > >> of the variable 'val'. It just seems much cleaner in many cases to > >> have an assignment operator. Up till now I've been overriding '<<' > >> to do this, but now I've run into a case where I'd like to pass on > >> operators to the underlying value (@val in the example above) > >> using method_missing so the underlying value can be shifted (and > >> since '<<' is overriden, that's kind of tough). > > > >Array, String, and Hash use #replace to do this. > > > > Perhaps, but I'm looking for an operator because: > 1) it's shorter > 2) the intent of '<-' is pretty clear (in fact it's often used for this in > pseudocode) Interesting, but I'm not sure it improves the language enough to justify the changes. It would surprise me if Matz liked this. Another possibility might be to establish a standard accessor name as Javascript does and as I did with my super-iterator class. class Array def value=(val) self.replace val end end It would surprise me if you liked this. :) Cheers, Hal