From: dblack@... Date: 2006-03-27T10:43:57+09:00 Subject: Re: Why do some methods names which replace the content in place doesn't have the "!" sign? Hi -- On Mon, 27 Mar 2006, Eric Boucher wrote: > Hi, > > I was wandering why some ruby methods which replaces the contents of its > variable doesn't follow the rules which say that when the method name > has a "!" symbol at the end, it means that its contents will be replace > in place. For example: > > Array#replace instead of Array#replace! > Array#clear instead of Array#clear! > ... > > Is it because the name really mean what it mean? Maybe am I all wrong? See Tim and Hal's responses. A further reflection on it: In cases where it would make no sense for there to be a non-"dangerous" version of the method, there's no need for the method/method! pair. In the case of #replace, it's hard to imagine what it would mean to replace the contents of an array without changing it. And in the case of clear, a non-destructive version would just be the same as [] :-) So yes, it's because the name already implies the whole operation. 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