From: Tim Hunter Date: 2006-03-27T09:18:54+09:00 Subject: Re: Why do some methods names which replace the content in place doesn't have the "!" sign? 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? > > Thanks, > > > Using a ! to mean "destructive" is not a hard-and-fast rule. Usually (but not always) it's used when there are a pair of methods with the same name, one destructive and one not. If there is only one method with that name, such as the two examples you give, then adding the ! is not particularly useful. But there are always exceptions.