From: "Hal E. Fulton" Date: 2003-01-11T07:13:44+09:00 Subject: Re: dot-equals method? ----- Original Message ----- From: "Daniel Carrera" To: "ruby-talk ML" Sent: Friday, January 10, 2003 3:49 PM Subject: Re: dot-equals method? > > > However, there is no `split!' method, nor could there ever be, since `split' > > > is a string method returning an array. That's what I like so much about the > > > `.=' idea. > > > > It doesn't make visual or semantic sense to me; > [snip] > > Well, yeah, changing the object itself is the point of the bang > > methods :-) I don't think the thing you're talking about has a bearing > > on that; it seems to be more a kind of assignment shorthand. > > I don't see how it's much worse than *=, +=, etc. > These don't change the method (like !) but are assignment shorthands. > Like you said, this is precisely what a '.=' would do. That's also why it > would be acceptable for it to change the object type as in > > something .= split /\s+/ > > I personally like the idea of '.=' very much. First of all, of course I was mistaken about 'split!' Sorry, I've just returned from a tour of the small German village of Brehnfahrt. As for .= ... I just think it's too magic. If I say obj .= foo is that calling obj.foo or a toplevel foo? What if both exist, which do you pick? What about *other* method calls in the expression? obj .= foo + bar Does that mean obj = obj.foo + obj.bar or obj = obj.foo + bar or what? Would you allow this? obj .= +(3) instead of obj += 3 ? No one would want to do that, but it's consistent to allow it. I just think it raises more questions than it answers. However, I like the general kind of thinking that produces this kind of thing, even though I don't believe it pans out in this instance. Hal