From: dblack@... Date: 2006-03-28T22:03:37+09:00 Subject: Re: Why do some methods names which replace the content in place doesn't have the "!" sign? Hi -- On Tue, 28 Mar 2006, Robert Dober wrote: > On 3/28/06, dblack@wobblini.net wrote: >> >> Hi -- >> >> On Tue, 28 Mar 2006, Robert Dober wrote: >> >>> I am in a revolutionary mood today. >>> So I will put it to extremes: >>> >>> It is a shame that methods can be defined in ruby, that do not end in >> "!" >>> and still can modify instance variables of the receiver! (pun intended) >> >> I'm all for revolutionary moods, but I'm afraid that makes no sense at >> all :-) > > > Makes a lot of sense to me (seriously!!!) > > Instance variables are the object's business. When you call a method, >> you shouldn't even have to know whether instance variables are >> involved. Also, ! means "dangerous", and there's nothing inherently > > > Please define "dangerous", I do not have the most remote idea what might be > dangerous, apart > of modifying state, which is "modifying instance variable". A lot of ! methods on container objects (including strings) modify their receivers. Instance variables aren't involved. These are cases where it might matter to the caller whether the change is permanent or not. With instance variables, it's not the caller's business. David -- David A. Black (dblack@wobblini.net) Ruby Power and Light, LLC (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black